28 #ifndef INCLUDE_OLA_NETWORK_SOCKET_H_
29 #define INCLUDE_OLA_NETWORK_SOCKET_H_
35 #include <ola/io/Descriptor.h>
36 #include <ola/io/IOQueue.h>
54 virtual bool Init() = 0;
58 bool Bind(
const IPV4Address &ip,
unsigned short port) {
64 virtual bool Close() = 0;
65 virtual ola::io::DescriptorHandle ReadDescriptor()
const = 0;
66 virtual ola::io::DescriptorHandle WriteDescriptor()
const = 0;
68 virtual ssize_t SendTo(
const uint8_t *buffer,
71 unsigned short port)
const = 0;
72 virtual ssize_t SendTo(
const uint8_t *buffer,
77 unsigned short port)
const = 0;
81 virtual bool RecvFrom(uint8_t *buffer, ssize_t *data_read)
const = 0;
82 virtual bool RecvFrom(uint8_t *buffer,
85 virtual bool RecvFrom(uint8_t *buffer,
88 uint16_t &port)
const = 0;
90 virtual bool EnableBroadcast() = 0;
91 virtual bool SetMulticastInterface(
const IPV4Address &iface) = 0;
92 virtual bool JoinMulticast(
const IPV4Address &iface,
94 bool loop =
false) = 0;
95 virtual bool LeaveMulticast(
const IPV4Address &iface,
97 virtual bool SetTos(uint8_t tos) = 0;
111 m_handle(ola::io::INVALID_DESCRIPTOR),
112 m_bound_to_port(
false) {}
120 ola::io::DescriptorHandle ReadDescriptor()
const {
return m_handle; }
121 ola::io::DescriptorHandle WriteDescriptor()
const {
return m_handle; }
122 ssize_t SendTo(
const uint8_t *buffer,
125 unsigned short port)
const;
126 ssize_t SendTo(
const uint8_t *buffer,
129 return SendTo(buffer, size, dest.Host(), dest.Port());
133 unsigned short port)
const;
136 return SendTo(data, dest.Host(), dest.Port());
139 bool RecvFrom(uint8_t *buffer, ssize_t *data_read)
const;
140 bool RecvFrom(uint8_t *buffer,
143 bool RecvFrom(uint8_t *buffer,
146 uint16_t &port)
const;
148 bool EnableBroadcast();
156 bool SetTos(uint8_t tos);
159 ola::io::DescriptorHandle m_handle;
160 bool m_bound_to_port;
166 #endif // INCLUDE_OLA_NETWORK_SOCKET_H_