Main Page Class Hierarchy Compound List File List Compound Members File Members

# /home/gilberto/prog/tesi2.31/TelepatiTcp/TCPConnection.h

Go to the documentation of this file.

    00001
    00003 #ifndef TCPConnection_h_DEFINExD
    00004 #define TCPConnection_h_DEFINED
    00005
    00006 #include <ant.h>
    00007 #include <IPAddress.h>
    00008 #include <OPENR/OSyslog.h>
    00009
    00011 enum ConnectionState {
    00012
    00013   CONNECTION_INVALID=0,
    00014   CONNECTION_CONNECTING=1,
    00015   CONNECTION_CONNECTED=2,
    00016   CONNECTION_WAITING=3,
    00017   CONNECTION_LISTENING=4,
    00018   CONNECTION_SENDING=5,
    00019   CONNECTION_RECEIVING=6,
    00020   CONNECTION_CLOSING=7,
    00021   CONNECTION_CLOSED=8
    00022 };
    00023
    00030 class TCPConnection {
    00031  public:
    00033   TCPConnection() { state= CONNECTION_INVALID; };
    00037   TCPConnection(antStackRef ipStack) {ipstackRef=ipStack; state = CONNECTION_CLOSED; };
    00039   virtual ~TCPConnection() {};
    00040
    00044   inline antModuleRef& getEndpoint() {return endpoint;};
    00045
    00048   inline void setState(ConnectionState st) {state = st;};
    00051   inline ConnectionState getState() { return state;};
    00052
    00055   inline void setPort(Port prt) {port=prt;};
    00058   inline Port getPort() {return port;};
    00059
    00063   virtual OStatus initConnection() = 0;
    00067   virtual OStatus stop() = 0;
    00068
    00069  protected:
    00071   antModuleRef endpoint;
    00073   antStackRef ipstackRef;
    00074
    00076   ConnectionState state;
    00078   Port port;
    00079 };
    00080
    00085 class TCPRecvConnection : public TCPConnection {
    00086  public:
    00088   TCPRecvConnection() {};
    00093   TCPRecvConnection(antStackRef ipStack, int bs);
    00094
    00096   ~TCPRecvConnection();
    00097
    00101   OStatus initConnection();
    00105   OStatus stop();
    00106
    00110   inline byte* getRecvData() { return recvData;};
    00116   inline int getRecvSize() { return recvSize;}
    00122   inline void setRecvSize(int size) { recvSize=size;}
    00123
    00124  private:
    00125
    00126   /* Buffer di ricezione*/
    00127   antSharedBuffer recvBuffer;
    00128   /* Puntatore ai dati contenunti nel buffer di ricezione*/
    00129   byte* recvData;
    00130   /* Dimensione buffer di Ricezine*/
    00131   int recvSize;
    00132
    00133   /* Inizializza il buffer. @return oSUCCESS in caso si successo;
    00134      oFAIL altrimenti*/
    00135   OStatus initBuffer();
    00136   /* Crea l'Endpoint- @return oSUCCESS in caso si successo; oFAIL
    00137      altrimenti*/
    00138   OStatus initTcpEndpoint();
    00139
    00140 };
    00141
    00142
    00147 class TCPSendConnection : public TCPConnection {
    00148  public:
    00150   TCPSendConnection() {};
    00155   TCPSendConnection(antStackRef ipStack, int bs);
    00156
    00158   ~TCPSendConnection();
    00159
    00163   OStatus initConnection();
    00167   OStatus stop();
    00168
    00172   inline byte* getSendData() {return sendData;};
    00178   inline int getSendSize() { return sendSize;}
    00184   inline void setSendSize(int size) { sendSize=size;}
    00185  private:
    00186
    00187   /* Buffer di spedizione*/
    00188   antSharedBuffer sendBuffer;
    00189   /* Puntatore ai dati contenunti nel buffer di spedizione*/
    00190   byte* sendData;
    00191   /* Dimensione del buffer*/
    00192   int bufferSize;
    00193
    00194   /* Dimensione dei dati da spedire*/
    00195   int sendSize;
    00196
    00197   /* Inizializza il buffer. @return oSUCCESS in caso si successo;
    00198      oFAIL altrimenti*/
    00199   OStatus initBuffer();
    00200   /* Crea l'Endpoint. @return oSUCCESS in caso si successo; oFAIL
    00201      altrimenti*/
    00202   OStatus initTcpEndpoint();
    00203 };
    00204
    00205 #endif // TCPConnection_h_DEFINED