36 #ifndef RCDISCOVER_SOCKET_LINUX_H 37 #define RCDISCOVER_SOCKET_LINUX_H 43 #include <netinet/in.h> 69 static SocketLinux create(in_addr_t dst_ip, uint16_t port, std::string iface_name);
89 in_addr_t dst_ip, uint16_t port,
90 std::string iface_name);
118 void bindImpl(
const sockaddr_in &addr);
124 void sendImpl(
const std::vector<uint8_t> &sendbuf);
153 #endif // RCDISCOVER_SOCKET_LINUX_H void bindToDevice(const std::string &device)
Binds this socket to a specific device (root privileges are required).
const int & getHandleImpl() const
Returns the native socket handle.
static std::vector< SocketLinux > createAndBindForAllInterfaces(uint16_t port)
Creates sockets for all interfaces and binds them to the respective interface.
const sockaddr_in & getDestSockAddr() const
Returns the sockaddr to which the socket is bound.
int SocketType
Type representing the native socket handle type.
void sendImpl(const std::vector< uint8_t > &sendbuf)
Sends data.
CRTP class for platform specific socket implementation.
SocketLinux(int domain, int type, int protocol, in_addr_t dst_ip, uint16_t port, std::string iface_name)
Constructor.
static const in_addr_t & getBroadcastAddr()
Returns the broadcast address.
void enableNonBlockingImpl()
Enables non-blocking operation for this socket.
void bindImpl(const sockaddr_in &addr)
Binds the socket to a specific sockaddr.
static SocketLinux create(in_addr_t dst_ip, uint16_t port, std::string iface_name)
Create a new socket.
void enableBroadcastImpl()
Enables broadcast for this socket.
Socket implementation for Linux.
SocketLinux & operator=(SocketLinux &&other)