/*! * @file upd_socket.h * class to connect to other clients via udp */ #ifndef _UDP_SOCKET #define _UDP_SOCKET /* include this file, it contains some default definitions */ #include "netdefs.h" /* include base_object.h since all classes are derived from this one */ #include "network_socket.h" class UdpServerSocket; class UdpSocket : public NetworkSocket { public: UdpSocket(); UdpSocket( UdpServerSocket * serverSocket, IPaddress ip, int userId ); UdpSocket( std::string host, int port ); virtual ~UdpSocket(); virtual void connectToServer( std::string host, int port ); virtual void disconnectServer(); virtual bool writePacket(byte * data, int length); virtual int readPacket(byte * data, int maxLength); private: UdpServerSocket * serverSocket; //!< will get packets here int userId; //!< user id used by serverSocket IPaddress ip; //!< host,port UDPsocket socket; //!< socket used to send/recieve UDPpacket * packet; void init(); }; #endif /* _NETWORK_SOCKET */