Changeset 15 in flair-src for trunk/lib/FlairCore/src/TcpSocket.h
- Timestamp:
- 04/08/16 15:40:57 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/TcpSocket.h
r2 r15 16 16 #include <ConnectedSocket.h> 17 17 18 namespace flair 19 { 20 namespace core 21 { 22 /*! \class TcpSocket 23 * 24 * \brief Class encapsulating a TCP socket 25 * 26 */ 27 class TcpSocket:public ConnectedSocket { 28 public: 29 TcpSocket(const Object* parent,const std::string name,bool blockOnSend=false,bool blockOnReceive=true); 30 ~TcpSocket(); 31 void Listen(const unsigned int port,const std::string localAddress="ANY"); 32 TcpSocket *Accept(Time timeout=0); //should throw an exception if not a listening socket 33 bool Connect(const unsigned int distantPort,const std::string distantAddress,Time timeout=0); // timeout in milliseconds 34 ssize_t SendMessage(const char* message,size_t message_len,Time timeout=0); // timeout in milliseconds 35 ssize_t RecvMessage(char* buf,size_t buf_len,Time timeout=0); // timeout in milliseconds 18 namespace flair { 19 namespace core { 20 /*! \class TcpSocket 21 * 22 * \brief Class encapsulating a TCP socket 23 * 24 */ 25 class TcpSocket : public ConnectedSocket { 26 public: 27 TcpSocket(const Object *parent, const std::string name, 28 bool blockOnSend = false, bool blockOnReceive = true); 29 ~TcpSocket(); 30 void Listen(const unsigned int port, const std::string localAddress = "ANY"); 31 TcpSocket *Accept( 32 Time timeout = 0); // should throw an exception if not a listening socket 33 bool Connect(const unsigned int distantPort, const std::string distantAddress, 34 Time timeout = 0); // timeout in milliseconds 35 ssize_t SendMessage(const char *message, size_t message_len, 36 Time timeout = 0); // timeout in milliseconds 37 ssize_t RecvMessage(char *buf, size_t buf_len, 38 Time timeout = 0); // timeout in milliseconds 36 39 37 38 39 40 40 uint16_t NetworkToHost16(uint16_t data); 41 uint16_t HostToNetwork16(uint16_t data); 42 uint32_t NetworkToHost32(uint32_t data); 43 uint32_t HostToNetwork32(uint32_t data); 41 44 42 43 44 45 46 47 48 49 45 private: 46 int socket; // socket file descriptor 47 bool blockOnSend; 48 bool blockOnReceive; 49 bool isConnected; 50 unsigned int distantPort; 51 std::string distantAddress; 52 }; 50 53 51 54 } // end namespace core
Note:
See TracChangeset
for help on using the changeset viewer.