Thu, 11 Dec 2014 05:58:55 +0200
- code cleanup
- added network-related classes (bytestream, ipaddress, udp socket)
5 | 1 | #pragma once |
2 | #include "../main.h" | |
3 | #include "ipaddress.h" | |
4 | #include "bytestream.h" | |
5 | ||
6 | enum { MAX_DATAGRAM_LENGTH = 5120 }; | |
7 | ||
8 | struct Datagram | |
9 | { | |
10 | Bytestream data; | |
11 | IPAddress from; | |
12 | }; | |
13 | ||
14 | // ------------------------------------------------------------------------------------------------- | |
15 | // | |
16 | class UDPSocket | |
17 | { | |
18 | public: | |
19 | UDPSocket(); | |
20 | virtual ~UDPSocket(); | |
21 | ||
22 | METHOD bind (unsigned short port) -> bool; | |
23 | METHOD read (Datagram& datagram) -> bool; | |
24 | METHOD send (const Bytestream& data, const IPAddress& addr) -> bool; | |
25 | METHOD set_blocking (bool a) -> bool; | |
26 | ||
27 | private: | |
28 | IPAddress m_addr; | |
29 | String m_error; | |
30 | int m_socket; | |
31 | }; |