Last change
on this file since 8319 was
7954,
checked in by patrick, 19 years ago
|
trunk: merged the network branche back to trunk.
|
File size:
1.1 KB
|
Rev | Line | |
---|
[7540] | 1 | /*! |
---|
| 2 | * @file upd_socket.h |
---|
| 3 | * class to connect to other clients via udp |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _UDP_SOCKET |
---|
| 7 | #define _UDP_SOCKET |
---|
| 8 | |
---|
| 9 | /* include this file, it contains some default definitions */ |
---|
| 10 | #include "netdefs.h" |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | /* include base_object.h since all classes are derived from this one */ |
---|
| 14 | #include "network_socket.h" |
---|
| 15 | |
---|
| 16 | class UdpServerSocket; |
---|
| 17 | |
---|
| 18 | class UdpSocket : public NetworkSocket |
---|
| 19 | { |
---|
| 20 | public: |
---|
| 21 | UdpSocket(); |
---|
| 22 | UdpSocket( UdpServerSocket * serverSocket, IPaddress ip, int userId ); |
---|
| 23 | UdpSocket( std::string host, int port ); |
---|
| 24 | virtual ~UdpSocket(); |
---|
| 25 | |
---|
| 26 | virtual void connectToServer( std::string host, int port ); |
---|
| 27 | |
---|
| 28 | virtual void disconnectServer(); |
---|
| 29 | |
---|
| 30 | virtual bool writePacket(byte * data, int length); |
---|
| 31 | |
---|
| 32 | virtual int readPacket(byte * data, int maxLength); |
---|
| 33 | |
---|
| 34 | private: |
---|
| 35 | UdpServerSocket * serverSocket; //!< will get packets here |
---|
| 36 | int userId; //!< user id used by serverSocket |
---|
| 37 | IPaddress ip; //!< host,port |
---|
| 38 | UDPsocket socket; //!< socket used to send/recieve |
---|
| 39 | UDPpacket * packet; |
---|
| 40 | |
---|
| 41 | void init(); |
---|
| 42 | |
---|
| 43 | }; |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | #endif /* _NETWORK_SOCKET */ |
---|
Note: See
TracBrowser
for help on using the repository browser.