/*! * @file server_socket.h * waits for incoming connections */ #ifndef _SERVER_SOCKET #define _SERVER_SOCKET #ifdef HAVE_SDL_H #include #else #include #endif /* include this file, it contains some default definitions */ #include "netdefs.h" /* include base_object.h since all classes are derived from this one */ #include "base_object.h" #include "network_socket.h" //sleep when waiting for connections #define _MSECONDS_SLEEP_LISTEN 100 class ServerSocket : public BaseObject { public: #warning old socket structure ServerSocket(); ServerSocket(unsigned int port); ServerSocket(ConnectionType connectionType); ServerSocket(ConnectionType connectionType, unsigned int port ); virtual ~ServerSocket(); bool listen( unsigned int port ); NetworkSocket* getNewSocket( void ); void close(); inline bool isOk(){ return listenSocket!=NULL; } private: void init(); private: #warning old socket structure TCPsocket listenSocket; ConnectionType connectionType; //!< the connection type of the socket {TCP,UDP} TCPsocket listenSocketTCP; //!< tcp socket UDPsocket listenSocketUDP; //!< udp socket bool terminateThread; //!< true if thread terminated bool _isListening; //!< true if listening }; #endif