Class SocketWindows

Inheritance Relationships

Base Type

Class Documentation

class SocketWindows : public rcdiscover::Socket<SocketWindows>

Public Types

typedef SOCKET SocketType

Type representing the native socket handle type.

Public Functions

SocketWindows(int domain, int type, int protocol, ULONG 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

SocketWindows(SocketWindows &&other)
SocketWindows &operator=(SocketWindows &&other)
~SocketWindows()

Public Static Functions

static SocketWindows create(ULONG dst_ip, uint16_t port, std::string iface_name)

Create a new socket.

Parameters:
  • dst_ip – destination IP address

  • port – destination port

Returns:

the created socket

static std::vector<SocketWindows> 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 ULONG &getBroadcastAddr()

Returns the broadcast address.

Returns:

broadcast address

Protected Functions

const SOCKET &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.