23#ifndef INCLUDE_OLA_NETWORK_SOCKET_H_
24#define INCLUDE_OLA_NETWORK_SOCKET_H_
35#include <ola/io/IOQueue.h>
92 virtual ssize_t
SendTo(
const uint8_t *buffer,
95 unsigned short port)
const = 0;
104 virtual ssize_t
SendTo(
const uint8_t *buffer,
123 unsigned short port)
const = 0;
145 virtual bool RecvFrom(uint8_t *buffer, ssize_t *data_read)
const = 0;
177 uint16_t &port)
const = 0;
212 bool multicast_loop =
false) = 0;
243 m_handle(ola::io::INVALID_DESCRIPTOR),
244 m_bound_to_port(
false) {}
254 ssize_t
SendTo(
const uint8_t *buffer,
257 unsigned short port)
const;
258 ssize_t
SendTo(
const uint8_t *buffer,
263 unsigned short port)
const;
267 bool RecvFrom(uint8_t *buffer, ssize_t *data_read)
const;
274 uint16_t &port)
const;
284 bool multicast_loop =
false);
291 ola::io::DescriptorHandle m_handle;
292 bool m_bound_to_port;
Represents an IPv4 Address.
Represents Socket Addresses.
A file descriptor that supports both read & write.
Definition Descriptor.h:201
Definition IOVecInterface.h:53
Represents a IPv4 Address.
Definition IPV4Address.h:55
An IPv4 SocketAddress.
Definition SocketAddress.h:78
bool Bind(const IPV4SocketAddress &endpoint)
Bind this socket to an external address:port.
Definition Socket.cpp:107
ola::io::DescriptorHandle ReadDescriptor() const
Returns the read descriptor for this socket.
Definition Socket.h:252
bool JoinMulticast(const IPV4Address &iface, const IPV4Address &group, bool multicast_loop=false)
Join a multicast group.
Definition Socket.cpp:387
bool Init()
Initialize the socket.
Definition Socket.cpp:84
ola::io::DescriptorHandle WriteDescriptor() const
Returns the write descriptor for this socket.
Definition Socket.h:253
bool SetMulticastInterface(const IPV4Address &iface)
Set the outgoing interface to be used for multicast transmission.
Definition Socket.cpp:367
bool GetSocketAddress(IPV4SocketAddress *address) const
Return the local address this socket is bound to.
Definition Socket.cpp:158
bool LeaveMulticast(const IPV4Address &iface, const IPV4Address &group)
Leave a multicast group.
Definition Socket.cpp:427
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
bool EnableBroadcast()
Enable broadcasting for this socket.
Definition Socket.cpp:345
bool Close()
Close the socket.
Definition Socket.cpp:171
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 interface for UDPSockets.
Definition Socket.h:48
virtual ola::io::DescriptorHandle ReadDescriptor() const =0
Returns the read descriptor for this socket.
virtual bool SetTos(uint8_t tos)=0
Set the tos field for a socket.
virtual bool Bind(const IPV4SocketAddress &endpoint)=0
Bind this socket to an external address:port.
virtual bool LeaveMulticast(const IPV4Address &iface, const IPV4Address &group)=0
Leave a multicast group.
virtual bool Init()=0
Initialize the socket.
virtual ola::io::DescriptorHandle WriteDescriptor() const =0
Returns the write descriptor for this socket.
virtual ssize_t SendTo(const uint8_t *buffer, unsigned int size, const IPV4Address &ip, unsigned short port) const =0
Send data on this UDPSocket.
virtual ssize_t SendTo(ola::io::IOVecInterface *data, const IPV4SocketAddress &dest) const =0
Send data from an IOVecInterface.
virtual bool RecvFrom(uint8_t *buffer, ssize_t *data_read, IPV4Address &source, uint16_t &port) const =0
Receive data and record the src address & port.
virtual bool RecvFrom(uint8_t *buffer, ssize_t *data_read) const =0
Receive data.
virtual bool EnableBroadcast()=0
Enable broadcasting for this socket.
virtual bool SetMulticastInterface(const IPV4Address &iface)=0
Set the outgoing interface to be used for multicast transmission.
virtual bool Close()=0
Close the socket.
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 IPV4SocketAddress &dest) const =0
Send data on this UDPSocket.
virtual bool RecvFrom(uint8_t *buffer, ssize_t *data_read, IPV4SocketAddress *source)=0
Receive a datagram on the UDP Socket.
virtual ssize_t SendTo(ola::io::IOVecInterface *data, const IPV4Address &ip, unsigned short port) const =0
Send data from an IOVecInterface.
virtual bool RecvFrom(uint8_t *buffer, ssize_t *data_read, IPV4Address &source) const =0
Receive data.
virtual bool JoinMulticast(const IPV4Address &iface, const IPV4Address &group, bool multicast_loop=false)=0
Join a multicast group.
The namespace containing all OLA symbols.
Definition Credentials.cpp:44