sources/network/udp.h

changeset 6
c709bb1a08e4
parent 5
146825d63b9a
child 7
01e4e9ae323a
equal deleted inserted replaced
5:146825d63b9a 6:c709bb1a08e4
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 };

mercurial