Rev | Line | |
---|
[5987] | 1 | /*! |
---|
| 2 | * @file server_socket.h |
---|
| 3 | * waits for incoming connections |
---|
| 4 | |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | #ifndef _SERVER_SOCKET |
---|
| 8 | #define _SERVER_SOCKET |
---|
| 9 | |
---|
| 10 | #ifdef HAVE_SDL_H |
---|
| 11 | #include <SDL_thread.h> |
---|
| 12 | #else |
---|
| 13 | #include <SDL/SDL_thread.h> |
---|
| 14 | #endif |
---|
| 15 | /* include this file, it contains some default definitions */ |
---|
| 16 | #include "netdefs.h" |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | /* include base_object.h since all classes are derived from this one */ |
---|
| 20 | #include "base_object.h" |
---|
| 21 | #include "network_socket.h" |
---|
| 22 | |
---|
| 23 | //sleep when waiting for connections |
---|
| 24 | #define _MSECONDS_SLEEP_LISTEN 100 |
---|
| 25 | |
---|
[7402] | 26 | |
---|
[5987] | 27 | class ServerSocket : public BaseObject |
---|
| 28 | { |
---|
| 29 | public: |
---|
[7402] | 30 | #warning old socket structure |
---|
[5987] | 31 | ServerSocket(); |
---|
[7402] | 32 | ServerSocket(unsigned int port); |
---|
| 33 | |
---|
| 34 | ServerSocket(ConnectionType connectionType); |
---|
| 35 | ServerSocket(ConnectionType connectionType, unsigned int port ); |
---|
[6981] | 36 | virtual ~ServerSocket(); |
---|
[7402] | 37 | |
---|
[5987] | 38 | bool listen( unsigned int port ); |
---|
[6139] | 39 | NetworkSocket* getNewSocket( void ); |
---|
| 40 | void close(); |
---|
| 41 | inline bool isOk(){ return listenSocket!=NULL; } |
---|
[7402] | 42 | |
---|
| 43 | |
---|
| 44 | private: |
---|
| 45 | void init(); |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | private: |
---|
| 49 | #warning old socket structure |
---|
| 50 | TCPsocket listenSocket; |
---|
| 51 | |
---|
| 52 | ConnectionType connectionType; //!< the connection type of the socket {TCP,UDP} |
---|
| 53 | TCPsocket listenSocketTCP; //!< tcp socket |
---|
| 54 | UDPsocket listenSocketUDP; //!< udp socket |
---|
| 55 | bool terminateThread; //!< true if thread terminated |
---|
| 56 | |
---|
| 57 | bool _isListening; //!< true if listening |
---|
| 58 | |
---|
| 59 | |
---|
[5987] | 60 | }; |
---|
| 61 | |
---|
| 62 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.