sources/network/udpsocket.h

branch
protocol5
changeset 106
7b156b764d11
parent 88
08ccaf26cffd
child 109
e4966d7e615d
equal deleted inserted replaced
104:a76af67a3a4b 106:7b156b764d11
30 30
31 #pragma once 31 #pragma once
32 #include "../main.h" 32 #include "../main.h"
33 #include "ipaddress.h" 33 #include "ipaddress.h"
34 #include "bytestream.h" 34 #include "bytestream.h"
35 BEGIN_ZFC_NAMESPACE
35 36
36 enum { MAX_DATAGRAM_LENGTH = 5120 }; 37 enum { MAX_DATAGRAM_LENGTH = 5120 };
37 38
38 struct Datagram 39 struct Datagram
39 { 40 {
47 { 48 {
48 public: 49 public:
49 UDPSocket(); 50 UDPSocket();
50 virtual ~UDPSocket(); 51 virtual ~UDPSocket();
51 52
52 METHOD bind (unsigned short port) -> bool; 53 bool bind (unsigned short port);
53 METHOD read (Datagram& datagram) -> bool; 54 bool read (Datagram& datagram);
54 METHOD send (const IPAddress& address, const Bytestream& data) -> bool; 55 bool send (const IPAddress& address, const Bytestream& data);
55 METHOD set_blocking (bool a) -> bool; 56 bool set_blocking (bool a);
56 inline METHOD error_string() -> const String&; 57 const String& error_string() const { return m_error; }
57 inline METHOD file_descriptor() -> int; 58 int file_descriptor() const { return m_socket; }
58 59
59 private: 60 private:
61 static char HuffmanBuffer[131072];
62
60 IPAddress m_addr; 63 IPAddress m_addr;
61 String m_error; 64 String m_error;
62 int m_socket; 65 int m_socket;
63 }; 66 };
64 67
65 // ------------------------------------------------------------------------------------------------- 68 END_ZFC_NAMESPACE
66 //
67 inline METHOD
68 UDPSocket::file_descriptor() -> int
69 {
70 return m_socket;
71 }
72
73 // -------------------------------------------------------------------------------------------------
74 //
75 inline METHOD
76 UDPSocket::error_string() -> const String&
77 {
78 return m_error;
79 }

mercurial