/*! * @file network_socket.h * Main interface for the network module. Manages all the modules */ #ifndef _NETWORK_SOCKET #define _NETWORK_SOCKET #define _INCOMING_BUFFER_SIZE 10240 #define _LOCAL_BUFFER_SIZE 1024 /* contains memmove and memcpy */ #include #include /* 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" /* using namespace std is default, this needs to be here */ using namespace std; class NetworkSocket : public BaseObject { private: // IPaddress serverAddress; // unsigned int port; TCPsocket tcpSocket; // UDPsocket udpSocket; byte buf[_INCOMING_BUFFER_SIZE]; int bufferlength; SDL_mutex * mutex; SDL_mutex * socketmutex; bool terminateThread; static int thread_listen(void * data); static int thread_read(void * data); public: NetworkSocket(); ~NetworkSocket(); void connectToServer(IPaddress ip, unsigned int port); void listen(unsigned int port); void disconnectServer(); int writeBytes(byte * data, int length); int readBytes(byte * data, int length); }; #endif /* _NETWORK_SOCKET */