00001
00002 #ifndef LMSG_TRANSPORTTCP_HH
00003 #define LMSG_TRANSPORTTCP_HH
00004
00005 #include "lmsg/MsgTypes.hh"
00006
00007 namespace lmsg {
00008 class Buffer;
00009 class BufferPool;
00010 class Message;
00011 class MsgAddr;
00012 class MsgHeader;
00013 class Socket;
00014 class TCPSocket;
00015
00024 class TransportTCP {
00025 public:
00026
00029 enum openflags {o_none, o_client=1, o_async=2};
00030
00034 TransportTCP(void);
00035
00039 ~TransportTCP(void);
00040
00045 MsgAddr getAddr(void) const;
00046
00051 bool isClient(void) const;
00052
00057 bool isConnected(void) const;
00058
00063 bool isOpen(void) const;
00064
00069 index_type getDebug(void) const;
00070
00079 error_type open(mask_type flags, const MsgAddr* addr=0);
00080
00084 void close(void);
00085
00093 error_type connect(const MsgAddr& addr);
00094
00099 error_type disconnect(void);
00100
00115 error_type receive(MsgHeader& from, char* b, size_type maxlen,
00116 wtime_type timeout=-1.0);
00117
00130 error_type receive(MsgHeader& from, Message& msg, wtime_type timeout=-1.0);
00131
00144 error_type receive(Buffer** Data, wtime_type timeout=-1.0);
00145
00155 error_type send(const MsgHeader& to, const char* b);
00156
00165 error_type send(const MsgHeader& to, const Message& b);
00166
00172 error_type waitMsg(wtime_type Timeout);
00173
00178 void Purge(void);
00179
00185 void setBufferPool(BufferPool* pool);
00186
00191 void setDebug(index_type level);
00192
00193 private:
00194 error_type send(Buffer* b);
00195
00196 private:
00197 mask_type mFlags;
00198 TCPSocket* mSocket;
00199 TCPSocket* mCSocket;
00200 BufferPool* mBuffPool;
00201 index_type mDebug;
00202 };
00203 }
00204
00205 inline bool
00206 lmsg::TransportTCP::isOpen(void) const {
00207 return (mSocket != 0);
00208 }
00209
00210 inline bool
00211 lmsg::TransportTCP::isClient(void) const {
00212 return (mFlags & o_client);
00213 }
00214
00215 inline lmsg::index_type
00216 lmsg::TransportTCP::getDebug(void) const {
00217 return mDebug;
00218 }
00219
00220 #endif // LMSG_TRANSPORTTCP_HH