simple-socket library 1.9.0
Loading...
Searching...
No Matches
NET Namespace Reference

Classes

class  CANRawSocket
 Raw CAN socket class. More...
class  CANSocket
 CAN socket class. More...
class  EventHandler
class  InternetSocket
 Internet socket class. More...
struct  NetworkAddressInfo
class  NetworkInterface
class  SCTPSocket
 SCTP socket class. More...
class  SocketException
 Signals a problem with the execution of a socket call. More...
struct  IOResult
class  SimpleSocket
 A socket representing a basic communication endpoint. More...
class  TCPSocket
 TCP socket class. More...
class  UDPSocket
 UDP socket class. More...
class  UnixDatagramSocket
 Unix datagram socket class. More...
class  UnixSeqPacketSocket
 Unix domain sequential packet (SOCK_SEQPACKET) socket class. More...
class  UnixSocket
 Unix domain socket class. More...
class  UnixStreamSocket
 Unix domain stream socket class. More...

Enumerations

enum  AddressFamily { IPv4 , IPv6 }
 used by internet socket types More...
enum class  IOStatus {
  Success , WouldBlock , Timeout , PeerDisconnected ,
  DestinationUnavailable
}
 status of the I/O operation More...
enum class  ConnectResult {
  Connected , InProgress , Timeout , Refused ,
  Aborted , Unreachable
}
 result of the connection attempt More...
enum  ShutdownDirection { STOP_RECEIVE , STOP_SEND , STOP_BOTH }
 direction to close for a stream socket More...

Functions

std::vector< NetworkAddressInfo > getNetworkAddresses ()
 Return IPv4/IPv6 address entries for the local network interfaces.
std::vector< NetworkInterface > getNetworkInterfaces ()
 Returns list of all network interfaces regardless of their state.
std::string resolveHostname (const std::string &hostname)
uint16_t resolveService (const std::string &service, const std::string &protocol="tcp")

Enumeration Type Documentation

◆ AddressFamily

used by internet socket types

Enumerator
IPv4 
IPv6 

Definition at line 45 of file SimpleSocket.h.

◆ ConnectResult

enum class NET::ConnectResult
nodiscardstrong

result of the connection attempt

Enumerator
Connected 

the connection is established

InProgress 

the attempt is still pending, check again with finishConnect()

Timeout 

the attempt timed out and was given up

Refused 

the peer refused the connection

Aborted 

the connection attempt was aborted or reset

Unreachable 

no route to the host or network

Definition at line 93 of file SimpleSocket.h.

◆ IOStatus

enum class NET::IOStatus
nodiscardstrong

status of the I/O operation

Enumerator
Success 
WouldBlock 
Timeout 
PeerDisconnected 
DestinationUnavailable 

Definition at line 55 of file SimpleSocket.h.

◆ ShutdownDirection

direction to close for a stream socket

Enumerator
STOP_RECEIVE 

disable all variants of receive() on the socket, send calls still work

STOP_SEND 

disable all variants of send() on the socket, receive calls still work

STOP_BOTH 

disable all send() and receive() calls on the socket

Definition at line 104 of file SimpleSocket.h.

Function Documentation

◆ getNetworkAddresses()

std::vector< NetworkAddressInfo > NET::getNetworkAddresses ( )

Return IPv4/IPv6 address entries for the local network interfaces.

One NetworkAddressInfo is returned per address, so an interface can occur multiple times when it has multiple IPv4/IPv6 addresses. Link-layer entries (AF_PACKET / AF_LINK) are ignored.

Returns
interface address entries returned by getifaddrs()

◆ getNetworkInterfaces()

std::vector< NetworkInterface > NET::getNetworkInterfaces ( )

Returns list of all network interfaces regardless of their state.

This function does not understand interfaces with multiple addresses For example when using zeroconf (eth0, eth0:avahi) it would only list eth0 In this case eth0 does not have an ip address yet and getInterfaceAddress("eth0") throws

Examples
mini_ifconfig.cpp.

◆ resolveHostname()

std::string NET::resolveHostname ( const std::string & hostname)

Resolve the specified hostname to a standard IPv4 address. If the operating system doesn't know the hostname yet this means a DNS lookup.

Parameters
hostnamedomain name
Returns
resolved hostname as standard IPv4 address
Examples
TCP_Client.cpp.

◆ resolveService()

uint16_t NET::resolveService ( const std::string & service,
const std::string & protocol = "tcp" )

Resolve the specified service for the specified protocol to the corresponding port number in host byte order.

Parameters
serviceservice to resolve (e.g. "http")
protocolprotocol of service to resolve. Default is "tcp". To match to any protocol, pass an empty string ("").
Returns
port number fetched from the database. 0 if no match found.