VideoTools
|
A class that holds a host/service name pair and the preferred address family (if any), and also the results of a name-to-address lookup, ie. More...
#include <glocation.h>
Public Member Functions | |
Location (const std::string &host, const std::string &service, int family=AF_UNSPEC) | |
Constructor taking a host/service string. | |
Location (const std::string &location_string, int family=AF_UNSPEC) | |
Constructor taking a formatted host/service string, also supporting an extended format for socks. More... | |
bool | socks () const |
Returns true if a socks location. | |
std::string | host () const |
Returns the remote host name, as passed in to the constructor. | |
std::string | service () const |
Returns the remote service name, as passed in to the constructor. | |
void | resolveTrivially () |
If host() and service() are already in address format then do a trivial update() so that the location is immediately resolved(), albeit with an empty canonical name(). More... | |
void | update (const Address &address, const std::string &canonical_name) |
Updates the address and canonical name, typically after doing a name lookup on host() and service(). More... | |
int | family () const |
Returns the preferred name resolution address family, or AF_UNSPEC. | |
bool | dgram () const |
Returns true if the name resolution should be specifically for datagram sockets. | |
bool | resolved () const |
Returns true after update() has been called. | |
Address | address () const |
Returns the remote address. | |
std::string | name () const |
Returns the remote canonical name. More... | |
std::string | displayString () const |
Returns a string representation for logging and debug. | |
G::EpochTime | updateTime () const |
Returns the time of the last update() or zero if never update()d. | |
unsigned int | socksFarPort () const |
Returns the port number for the socks far server. More... | |
std::string | socksFarHost () const |
Returns the port for the socks far server. More... | |
A class that holds a host/service name pair and the preferred address family (if any), and also the results of a name-to-address lookup, ie.
the remote address and canonical host name. The actual name-to-address lookup is done externally, and the results are deposited into the Location object with update().
An extended host/service format is used for SOCKS support: before the "@" separator is the host/service pair passed verbatim to the socks server for it to resolve (see socksFarHost()); after the "@" is the host/service pair for the socks server itself, which we resolve and connect to (see host()).
Definition at line 51 of file glocation.h.
|
explicit |
Constructor taking a formatted host/service string, also supporting an extended format for socks.
Throws if an invalid format.
Definition at line 47 of file glocation.cpp.
std::string GNet::Location::name | ( | ) | const |
Returns the remote canonical name.
Returns the empty string if not available.
Definition at line 140 of file glocation.cpp.
void GNet::Location::resolveTrivially | ( | ) |
If host() and service() are already in address format then do a trivial update() so that the location is immediately resolved(), albeit with an empty canonical name().
Definition at line 112 of file glocation.cpp.
std::string GNet::Location::socksFarHost | ( | ) | const |
Returns the port for the socks far server.
Precondition: socks()
Definition at line 166 of file glocation.cpp.
unsigned int GNet::Location::socksFarPort | ( | ) | const |
Returns the port number for the socks far server.
Precondition: socks()
Definition at line 161 of file glocation.cpp.
void GNet::Location::update | ( | const Address & | address, |
const std::string & | canonical_name | ||
) |
Updates the address and canonical name, typically after doing a name lookup on host() and service().
Definition at line 129 of file glocation.cpp.