simple-socket library 1.1.5
Classes | Functions

NET Namespace Reference

Classes

class  InternetSocket
 Internet socket class. More...
class  SCTPSocket
 SCTP socket class. More...
class  SimpleSocket
class  SocketException
 Signals a problem with the execution of a socket call. More...
class  SocketHandle
 A simple class to provide strict ownership of socket handles. More...
class  TCPSocket
 TCP socket class. More...
class  UDPSocket
 UDP socket class. More...
class  UnixDatagramSocket
 Unix datagram socket class. More...
class  UnixSocket
 Unix domain socket class. More...

Functions

std::string getBroadcastAddress (const std::string &interface)
 Return the IPv4 broadcast address of the given network interface.
std::string getDestinationAddress (const std::string &interface)
 Return the IPv4 destination address of the given network interface.
std::string getHardwareAddress (const std::string &interface, char separationChar= ':')
 Return the MAC address of the given network interfaces.
std::string getInterfaceAddress (const std::string &interface)
 Return the IPv4 address of the given network interface.
int getMTU (const std::string &interface)
 Return the MTU (Maximum Transmission Unit) of the given network interface in bytes.
std::string getNetmask (const std::string &interface)
 Return the IPv4 netmask of the given network interface.
std::vector< std::string > getNetworkInterfaces ()
 Return a list of available network interfaces.
std::string resolveHostname (const std::string &hostname)
unsigned short resolveService (const std::string &service, const std::string &protocol="tcp")
void setBroadcastAddress (const std::string &interface, const std::string &address)
 Set the IPv4 broadcast address of the given network interface.
void setDestinationAddress (const std::string &interface, const std::string &address)
 Set the IPv4 destination address of the given network interface.
void setInterfaceAddress (const std::string &interface, const std::string &address)
 Set the IPv4 address of the given network interface.
void setMTU (const std::string &interface, int mtu)
 Set the MTU (Maximum Transmission Unit) of the given network interface in bytes.
void setNetmask (const std::string &interface, const std::string &address)
 Set the IPv4 netmask of the given network interface.

Function Documentation

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

Definition at line 32 of file SocketUtils.cpp.

unsigned short 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".

Definition at line 43 of file SocketUtils.cpp.

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

Return a list of available network interfaces.

Definition at line 55 of file SocketUtils.cpp.

std::string NET::getInterfaceAddress ( const std::string &  interface)

Return the IPv4 address of the given network interface.

Definition at line 67 of file SocketUtils.cpp.

void NET::setInterfaceAddress ( const std::string &  interface,
const std::string &  address 
)

Set the IPv4 address of the given network interface.

Definition at line 86 of file SocketUtils.cpp.

std::string NET::getBroadcastAddress ( const std::string &  interface)

Return the IPv4 broadcast address of the given network interface.

The IOCTL call SIOCGIFBRDADDR is used on the specified interface. This method only works on AF_INET interfaces, it therefore works only on interfaces returned by ifconfig or getNetworkInterfaces().

Parameters:
interfacethe interface to query for its broadcast address
Returns:
the broadcast address formatted as an ip address

Definition at line 105 of file SocketUtils.cpp.

void NET::setBroadcastAddress ( const std::string &  interface,
const std::string &  address 
)

Set the IPv4 broadcast address of the given network interface.

Definition at line 124 of file SocketUtils.cpp.

std::string NET::getNetmask ( const std::string &  interface)

Return the IPv4 netmask of the given network interface.

Definition at line 143 of file SocketUtils.cpp.

void NET::setNetmask ( const std::string &  interface,
const std::string &  address 
)

Set the IPv4 netmask of the given network interface.

Definition at line 162 of file SocketUtils.cpp.

std::string NET::getDestinationAddress ( const std::string &  interface)

Return the IPv4 destination address of the given network interface.

Definition at line 181 of file SocketUtils.cpp.

void NET::setDestinationAddress ( const std::string &  interface,
const std::string &  address 
)

Set the IPv4 destination address of the given network interface.

Definition at line 200 of file SocketUtils.cpp.

int NET::getMTU ( const std::string &  interface)

Return the MTU (Maximum Transmission Unit) of the given network interface in bytes.

Definition at line 219 of file SocketUtils.cpp.

void NET::setMTU ( const std::string &  interface,
int  mtu 
)

Set the MTU (Maximum Transmission Unit) of the given network interface in bytes.

Definition at line 238 of file SocketUtils.cpp.

std::string NET::getHardwareAddress ( const std::string &  interface,
char  separationChar = ':' 
)

Return the MAC address of the given network interfaces.

Definition at line 257 of file SocketUtils.cpp.