uicore::SocketName Class Reference

Socket name; container class for an IP address and port. More...

#include <socket_name.h>

Public Member Functions

 SocketName ()
 Constructs a new socket name. More...
 
 SocketName (const std::string &port)
 
 SocketName (const std::string &address, const std::string &port)
 
const std::stringaddress () const
 Returns the address part of the socket name. More...
 
void from_sockaddr (int domain, sockaddr *addr, int len)
 Get the socket name from a C sockets sockaddr structure. More...
 
std::string lookup_hostname () const
 Perform a DNS lookup, if needed, for the hostname. More...
 
std::string lookup_ipv4 () const
 Perform a DNS lookup, if needed, for the IP v4 address. More...
 
bool operator< (const SocketName &other_instance) const
 
bool operator== (const SocketName &other_instance) const
 
const std::stringport () const
 Returns the port part of the socket name. More...
 
void set_address (const std::string &address)
 Set the IP address. More...
 
void set_name (const std::string &hostname, const std::string &port)
 Set the socket name using a hostname and port. More...
 
void set_port (const std::string &port)
 Set the IP port. More...
 
SocketName to_hostname ()
 Create socket name that uses the hostname as its address. More...
 
SocketName to_ipv4 ()
 Create socket name that uses the IP v4 address as its address. More...
 
void to_sockaddr (int domain, sockaddr *addr, int len) const
 Fill the socket name into a C sockets sockaddr structure. More...
 

Detailed Description

Socket name; container class for an IP address and port.

Constructor & Destructor Documentation

uicore::SocketName::SocketName ( )
inline

Constructs a new socket name.

If no address is specified, the socket address will default to INADDR_ANY. If no port is specified, it will default to port 0.

uicore::SocketName::SocketName ( const std::string port)
inline
uicore::SocketName::SocketName ( const std::string address,
const std::string port 
)
inline

Member Function Documentation

const std::string& uicore::SocketName::address ( ) const
inline

Returns the address part of the socket name.

Referenced by set_address().

void uicore::SocketName::from_sockaddr ( int  domain,
sockaddr *  addr,
int  len 
)

Get the socket name from a C sockets sockaddr structure.

std::string uicore::SocketName::lookup_hostname ( ) const

Perform a DNS lookup, if needed, for the hostname.

std::string uicore::SocketName::lookup_ipv4 ( ) const

Perform a DNS lookup, if needed, for the IP v4 address.

bool uicore::SocketName::operator< ( const SocketName other_instance) const
bool uicore::SocketName::operator== ( const SocketName other_instance) const
const std::string& uicore::SocketName::port ( ) const
inline

Returns the port part of the socket name.

Referenced by set_name(), and set_port().

void uicore::SocketName::set_address ( const std::string address)
inline

Set the IP address.

Parameters
addressCan be an IPv4 dotted-quad, hostname or a valid IPv6 address.

References address().

void uicore::SocketName::set_name ( const std::string hostname,
const std::string port 
)
inline

Set the socket name using a hostname and port.

Parameters
hostnameCan be an IPv4 dotted-quad, hostname or a valid IPv6 address.
portPort number.

References port().

void uicore::SocketName::set_port ( const std::string port)
inline

Set the IP port.

References port().

SocketName uicore::SocketName::to_hostname ( )

Create socket name that uses the hostname as its address.

SocketName uicore::SocketName::to_ipv4 ( )

Create socket name that uses the IP v4 address as its address.

void uicore::SocketName::to_sockaddr ( int  domain,
sockaddr *  addr,
int  len 
) const

Fill the socket name into a C sockets sockaddr structure.


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