23 #ifndef INCLUDE_OLA_NETWORK_SOCKET_H_
24 #define INCLUDE_OLA_NETWORK_SOCKET_H_
31 #include <ola/io/IOQueue.h>
54 virtual bool Init() = 0;
74 virtual bool Close() = 0;
89 virtual ssize_t
SendTo(
const uint8_t *buffer,
92 unsigned short port)
const = 0;
101 virtual ssize_t
SendTo(
const uint8_t *buffer,
120 unsigned short port)
const = 0;
142 virtual bool RecvFrom(uint8_t *buffer, ssize_t *data_read)
const = 0;
174 uint16_t &port)
const = 0;
184 virtual bool RecvFrom(uint8_t *buffer,
209 bool multicast_loop =
false) = 0;
225 virtual bool SetTos(uint8_t tos) = 0;
239 m_handle(ola::io::INVALID_DESCRIPTOR),
240 m_bound_to_port(
false) {}
250 ssize_t
SendTo(
const uint8_t *buffer,
253 unsigned short port)
const;
254 ssize_t
SendTo(
const uint8_t *buffer,
259 unsigned short port)
const;
263 bool RecvFrom(uint8_t *buffer, ssize_t *data_read)
const;
270 uint16_t &port)
const;
280 bool multicast_loop =
false);
287 ola::io::DescriptorHandle m_handle;
288 bool m_bound_to_port;
294 #endif // INCLUDE_OLA_NETWORK_SOCKET_H_
virtual bool LeaveMulticast(const IPV4Address &iface, const IPV4Address &group)=0
Leave a multicast group.
Represents Socket Addresses.
bool EnableBroadcast()
Enable broadcasting for this socket.
Definition: Socket.cpp:345
virtual bool GetSocketAddress(IPV4SocketAddress *address) const =0
Return the local address this socket is bound to.
virtual ssize_t SendTo(const uint8_t *buffer, unsigned int size, const IPV4Address &ip, unsigned short port) const =0
Send data on this UDPSocket.
bool JoinMulticast(const IPV4Address &iface, const IPV4Address &group, bool multicast_loop=false)
Join a multicast group.
Definition: Socket.cpp:387
The interface for UDPSockets.
Definition: Socket.h:45
bool Close()
Close the socket.
Definition: Socket.cpp:171
virtual bool SetMulticastInterface(const IPV4Address &iface)=0
Set the outgoing interface to be used for multicast transmission.
bool SetMulticastInterface(const IPV4Address &iface)
Set the outgoing interface to be used for multicast transmission.
Definition: Socket.cpp:367
virtual bool RecvFrom(uint8_t *buffer, ssize_t *data_read) const =0
Receive data.
virtual bool Init()=0
Initialize the socket.
virtual bool JoinMulticast(const IPV4Address &iface, const IPV4Address &group, bool multicast_loop=false)=0
Join a multicast group.
Represents a IPv4 Address.
Definition: IPV4Address.h:55
bool Bind(const IPV4SocketAddress &endpoint)
Bind this socket to an external address:port.
Definition: Socket.cpp:107
A file descriptor that supports both read & write.
Definition: Descriptor.h:200
ssize_t SendTo(const uint8_t *buffer, unsigned int size, const IPV4Address &ip, unsigned short port) const
Send data on this UDPSocket.
Definition: Socket.cpp:193
virtual ola::io::DescriptorHandle WriteDescriptor() const =0
Returns the write descriptor for this socket.
virtual bool Bind(const IPV4SocketAddress &endpoint)=0
Bind this socket to an external address:port.
virtual ola::io::DescriptorHandle ReadDescriptor() const =0
Returns the read descriptor for this socket.
virtual bool Close()=0
Close the socket.
Definition: IOVecInterface.h:53
Represents an IPv4 Address.
bool SetTos(uint8_t tos)
Set the tos field for a socket.
Definition: Socket.cpp:450
bool RecvFrom(uint8_t *buffer, ssize_t *data_read) const
Receive data.
Definition: Socket.cpp:282
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
ola::io::DescriptorHandle ReadDescriptor() const
Returns the read descriptor for this socket.
Definition: Socket.h:248
bool LeaveMulticast(const IPV4Address &iface, const IPV4Address &group)
Leave a multicast group.
Definition: Socket.cpp:427
virtual bool SetTos(uint8_t tos)=0
Set the tos field for a socket.
An IPv4 SocketAddress.
Definition: SocketAddress.h:77
virtual bool EnableBroadcast()=0
Enable broadcasting for this socket.
bool Init()
Initialize the socket.
Definition: Socket.cpp:84
bool GetSocketAddress(IPV4SocketAddress *address) const
Return the local address this socket is bound to.
Definition: Socket.cpp:158
ola::io::DescriptorHandle WriteDescriptor() const
Returns the write descriptor for this socket.
Definition: Socket.h:249