Classes | |
class | clan::SocketName |
Socket name; container class for an IP address and port. More... | |
Construction | |
clan::SocketName::SocketName () | |
Constructs a new socket name. More... | |
clan::SocketName::SocketName (const std::string &port) | |
Constructs a SocketName. More... | |
clan::SocketName::SocketName (const std::string &address, const std::string &port) | |
Constructs a SocketName. More... | |
Attributes | |
std::string | clan::SocketName::get_address () const |
Returns the address part of the socket name. More... | |
std::string | clan::SocketName::get_port () const |
Returns the port part of the socket name. More... | |
bool | clan::SocketName::operator== (const SocketName &other_instance) const |
Returns true if objects are the same. More... | |
bool | clan::SocketName::operator< (const SocketName &other_instance) const |
Returns true if the other address is less. More... | |
bool | clan::SocketName::operator> (const SocketName &other_instance) const |
Returns true if the other address is greater. More... | |
Operations | |
void | clan::SocketName::set_name (const std::string &hostname, const std::string &port) |
Set the socket name using a hostname and port. More... | |
void | clan::SocketName::set_address (const std::string &address) |
Set the IP address. More... | |
void | clan::SocketName::set_port (const std::string &port) |
Set the IP port. More... | |
std::string | clan::SocketName::lookup_ipv4 () const |
Perform a DNS lookup, if needed, for the IP v4 address. More... | |
std::string | clan::SocketName::lookup_hostname () const |
Perform a DNS lookup, if needed, for the hostname. More... | |
SocketName | clan::SocketName::to_ipv4 () |
Create socket name that uses the IP v4 address as its address. More... | |
SocketName | clan::SocketName::to_hostname () |
Create socket name that uses the hostname as its address. More... | |
void | clan::SocketName::to_sockaddr (int domain, sockaddr *addr, int len) const |
Fill the socket name into a C sockets sockaddr structure. More... | |
void | clan::SocketName::from_sockaddr (int domain, sockaddr *addr, int len) |
Get the socket name from a C sockets sockaddr structure. More... | |
clan::SocketName::SocketName | ( | ) |
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.
clan::SocketName::SocketName | ( | const std::string & | address, |
const std::string & | port | ||
) |
Constructs a SocketName.
address | = String |
port | = String |
clan::SocketName::SocketName | ( | const std::string & | port | ) |
Constructs a SocketName.
port | = String |
void clan::SocketName::from_sockaddr | ( | int | domain, |
sockaddr * | addr, | ||
int | len | ||
) |
Get the socket name from a C sockets sockaddr structure.
std::string clan::SocketName::get_address | ( | ) | const |
Returns the address part of the socket name.
std::string clan::SocketName::get_port | ( | ) | const |
Returns the port part of the socket name.
std::string clan::SocketName::lookup_hostname | ( | ) | const |
Perform a DNS lookup, if needed, for the hostname.
std::string clan::SocketName::lookup_ipv4 | ( | ) | const |
Perform a DNS lookup, if needed, for the IP v4 address.
bool clan::SocketName::operator< | ( | const SocketName & | other_instance | ) | const |
Returns true if the other address is less.
This is used for sorting purposes (eg. if you use a std::map<SocketName, Socket>), and sorts the address based on lowest IP number address.
bool clan::SocketName::operator== | ( | const SocketName & | other_instance | ) | const |
Returns true if objects are the same.
bool clan::SocketName::operator> | ( | const SocketName & | other_instance | ) | const |
Returns true if the other address is greater.
This is used for sorting purposes (eg. if you use a std::map<SocketName, Socket>), and sorts the address based on lowest IP number address.
void clan::SocketName::set_address | ( | const std::string & | address | ) |
Set the IP address.
void clan::SocketName::set_name | ( | const std::string & | hostname, |
const std::string & | port | ||
) |
Set the socket name using a hostname and port.
hostname | Can be an IPv4 dotted-quad, hostname or a valid IPv6 address. |
port | Port number. |
void clan::SocketName::set_port | ( | const std::string & | port | ) |
Set the IP port.
SocketName clan::SocketName::to_hostname | ( | ) |
Create socket name that uses the hostname as its address.
SocketName clan::SocketName::to_ipv4 | ( | ) |
Create socket name that uses the IP v4 address as its address.
void clan::SocketName::to_sockaddr | ( | int | domain, |
sockaddr * | addr, | ||
int | len | ||
) | const |
Fill the socket name into a C sockets sockaddr structure.