Class SocketLinux
Defined in File socket_linux.h
Inheritance Relationships
Base Type
public rcdiscover::Socket< SocketLinux >
(Template Class Socket)
Class Documentation
-
class SocketLinux : public rcdiscover::Socket<SocketLinux>
Socket implementation for Linux.
Public Types
-
typedef int SocketType
Type representing the native socket handle type.
Public Functions
-
SocketLinux(int domain, int type, int protocol, in_addr_t dst_ip, uint16_t port, std::string iface_name)
Constructor.
- Parameters:
domain – domain of socket()
type – type of socket()
protocol – protocol of socket()
dst_ip – destination IP address
port – destination port
iface_name – name of the interface
-
SocketLinux(SocketLinux &&other)
-
SocketLinux &operator=(SocketLinux &&other)
-
~SocketLinux()
-
const sockaddr_in &getDestSockAddr() const
Returns the sockaddr to which the socket is bound.
- Returns:
sockaddr to which the socket is bound.
Public Static Functions
-
static SocketLinux create(in_addr_t dst_ip, uint16_t port, std::string iface_name)
Create a new socket.
- Parameters:
dst_ip – destination IP address
port – destination port
iface_name – name of the interface
- Returns:
the created socket
-
static std::vector<SocketLinux> createAndBindForAllInterfaces(uint16_t port)
Creates sockets for all interfaces and binds them to the respective interface.
- Parameters:
port – destination port
- Returns:
vector of sockets
-
static const in_addr_t &getBroadcastAddr()
Returns the broadcast address.
- Returns:
broadcast address
Protected Functions
-
const int &getHandleImpl() const
Returns the native socket handle.
- Returns:
native socket handle.
-
void bindImpl(const sockaddr_in &addr)
Binds the socket to a specific sockaddr.
- Parameters:
addr – sockaddr_in to which to bind the socket
-
void sendImpl(const std::vector<uint8_t> &sendbuf)
Sends data.
- Parameters:
sendbuf – data buffer
-
void enableBroadcastImpl()
Enables broadcast for this socket.
-
void enableNonBlockingImpl()
Enables non-blocking operation for this socket.
-
typedef int SocketType