Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
rcdiscover::SocketWindows Class Reference

#include <socket_windows.h>

Inheritance diagram for rcdiscover::SocketWindows:
Inheritance graph
[legend]

Public Types

typedef SOCKET SocketType
 Type representing the native socket handle type. More...
 

Public Member Functions

SocketWindowsoperator= (SocketWindows &&other)
 
 SocketWindows (int domain, int type, int protocol, ULONG dst_ip, uint16_t port, std::string iface_name)
 Constructor. More...
 
 SocketWindows (SocketWindows &&other)
 
 ~SocketWindows ()
 
- Public Member Functions inherited from rcdiscover::Socket< SocketWindows >
void bind (const sockaddr_in &addr)
 Binds the socket to an interface. More...
 
void enableBroadcast ()
 Enables broadcast for this socket. More...
 
void enableNonBlocking ()
 Enables non-blocking operation for this socket. More...
 
const T & getHandle () const
 Returns the native socket handle. More...
 
const std::string & getIfaceName () const
 Returns the interface name. More...
 
Socketoperator= (const Socket &)=delete
 
Socketoperator= (Socket &&)=default
 
void send (const std::vector< uint8_t > &sendbuf)
 Sends data. More...
 
 Socket (const Socket &)=delete
 
 Socket (Socket &&)=default
 
 Socket (std::string iface_name)
 

Static Public Member Functions

static SocketWindows create (ULONG dst_ip, uint16_t port, std::string iface_name)
 Create a new socket. More...
 
static std::vector< SocketWindowscreateAndBindForAllInterfaces (uint16_t port)
 Creates sockets for all interfaces and binds them to the respective interface. More...
 
static const ULONG & getBroadcastAddr ()
 Returns the broadcast address. More...
 

Protected Member Functions

void bindImpl (const sockaddr_in &addr)
 Binds the socket to a specific sockaddr. More...
 
void enableBroadcastImpl ()
 Enables broadcast for this socket. More...
 
void enableNonBlockingImpl ()
 Enables non-blocking operation for this socket. More...
 
const SOCKET & getHandleImpl () const
 Returns the native socket handle. More...
 
void sendImpl (const std::vector< uint8_t > &sendbuf)
 Sends data. More...
 

Private Attributes

sockaddr_in dst_addr_
 
SOCKET sock_
 

Friends

class Socket< SocketWindows >
 

Detailed Description

Definition at line 46 of file socket_windows.h.

Member Typedef Documentation

◆ SocketType

Type representing the native socket handle type.

Definition at line 54 of file socket_windows.h.

Constructor & Destructor Documentation

◆ SocketWindows() [1/2]

rcdiscover::SocketWindows::SocketWindows ( int  domain,
int  type,
int  protocol,
ULONG  dst_ip,
uint16_t  port,
std::string  iface_name 
)

Constructor.

Parameters
domaindomain of socket()
typetype of socket()
protocolprotocol of socket()
dst_ipdestination IP address
portdestination port

Definition at line 201 of file socket_windows.cc.

◆ SocketWindows() [2/2]

rcdiscover::SocketWindows::SocketWindows ( SocketWindows &&  other)

Definition at line 222 of file socket_windows.cc.

◆ ~SocketWindows()

rcdiscover::SocketWindows::~SocketWindows ( )

Definition at line 236 of file socket_windows.cc.

Member Function Documentation

◆ bindImpl()

void rcdiscover::SocketWindows::bindImpl ( const sockaddr_in &  addr)
protected

Binds the socket to a specific sockaddr.

Parameters
addrsockaddr_in to which to bind the socket

Definition at line 249 of file socket_windows.cc.

◆ create()

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

Create a new socket.

Parameters
dst_ipdestination IP address
portdestination port
Returns
the created socket

Definition at line 53 of file socket_windows.cc.

◆ createAndBindForAllInterfaces()

std::vector< SocketWindows > rcdiscover::SocketWindows::createAndBindForAllInterfaces ( uint16_t  port)
static

Creates sockets for all interfaces and binds them to the respective interface.

Parameters
portdestination port
Returns
vector of sockets

Definition at line 88 of file socket_windows.cc.

◆ enableBroadcastImpl()

void rcdiscover::SocketWindows::enableBroadcastImpl ( )
protected

Enables broadcast for this socket.

Definition at line 289 of file socket_windows.cc.

◆ enableNonBlockingImpl()

void rcdiscover::SocketWindows::enableNonBlockingImpl ( )
protected

Enables non-blocking operation for this socket.

Definition at line 303 of file socket_windows.cc.

◆ getBroadcastAddr()

const ULONG & rcdiscover::SocketWindows::getBroadcastAddr ( )
static

Returns the broadcast address.

Returns
broadcast address

Definition at line 47 of file socket_windows.cc.

◆ getHandleImpl()

const SOCKET & rcdiscover::SocketWindows::getHandleImpl ( ) const
protected

Returns the native socket handle.

Returns
native socket handle.

Definition at line 244 of file socket_windows.cc.

◆ operator=()

SocketWindows & rcdiscover::SocketWindows::operator= ( SocketWindows &&  other)

Definition at line 230 of file socket_windows.cc.

◆ sendImpl()

void rcdiscover::SocketWindows::sendImpl ( const std::vector< uint8_t > &  sendbuf)
protected

Sends data.

Parameters
sendbufdata buffer

Definition at line 259 of file socket_windows.cc.

Friends And Related Function Documentation

◆ Socket< SocketWindows >

friend class Socket< SocketWindows >
friend

Definition at line 48 of file socket_windows.h.

Member Data Documentation

◆ dst_addr_

sockaddr_in rcdiscover::SocketWindows::dst_addr_
private

Definition at line 126 of file socket_windows.h.

◆ sock_

SOCKET rcdiscover::SocketWindows::sock_
private

Definition at line 125 of file socket_windows.h.


The documentation for this class was generated from the following files:


rcdiscover
Author(s): Heiko Hirschmueller , Raphael Schaller
autogenerated on Thu Aug 1 2024 02:55:56