00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef CServerTCPSocket_H
00029 #define CServerTCPSocket_H
00030
00031 #include <mrpt/config.h>
00032 #include <mrpt/utils/utils_defs.h>
00033 #include <mrpt/utils/CStream.h>
00034
00035 #include <mrpt/utils/CDebugOutputCapable.h>
00036
00037 namespace mrpt
00038 {
00039 namespace utils
00040 {
00041 class CClientTCPSocket;
00042
00046 class MRPTDLLIMPEXP CServerTCPSocket : public utils::CDebugOutputCapable
00047 {
00048 private:
00049
00050 #ifdef MRPT_OS_WINDOWS
00051
00053 unsigned int m_serverSock;
00054 #endif
00055
00056 #ifdef MRPT_OS_LINUX
00057
00059 int m_serverSock;
00060 #endif
00061
00063 std::string getLastErrorStr();
00064
00065 bool m_verbose;
00066
00068 void setupSocket(
00069 unsigned short listenPort,
00070 const std::string &IPaddress,
00071 int maxConnectionsWaiting );
00072
00073 public:
00083 CServerTCPSocket(
00084 unsigned short listenPort,
00085 const std::string &IPaddress = std::string("127.0.0.1"),
00086 int maxConnectionsWaiting = 50,
00087 bool verbose = false
00088 );
00089
00092 ~CServerTCPSocket( );
00093
00096 bool isListening();
00097
00103 CClientTCPSocket * accept( int timeout_ms = -1 );
00104
00105
00106
00107 };
00108
00109 }
00110 }
00111
00112 #endif // file