21 #ifndef G_NET_LOCATION__H
22 #define G_NET_LOCATION__H
53 G_EXCEPTION( InvalidFormat ,
"invalid host:service format" ) ;
58 Location(
const std::string & socks_host ,
const std::string & socks_service ,
59 const std::string & far_host ,
const std::string & far_service ,
65 explicit Location(
const std::string & location_string ,
int family = AF_UNSPEC ) ;
74 std::string
host()
const ;
102 std::string
name()
const ;
121 static std::string head(
const std::string & ) ;
122 static std::string tail(
const std::string & ) ;
123 static bool socksified(
const std::string & , std::string & ,
unsigned int & ) ;
124 static std::string sockless(
const std::string & ) ;
128 std::string m_service ;
129 bool m_address_valid ;
133 std::string m_canonical_name ;
136 std::string m_socks_far_host ;
137 unsigned int m_socks_far_port ;
142 inline std::ostream & operator<<( std::ostream & stream ,
const Location & location )
A subsecond-resolution timestamp based on a time_t.
The GNet::Address class encapsulates a TCP/UDP transport address.
bool socks() const
Returns true if a socks location.
std::string displayString() const
Returns a string representation for logging and debug.
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.
bool dgram() const
Returns true if the name resolution should be specifically for datagram sockets.
std::string name() const
Returns the remote canonical name.
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()...
Address address() const
Returns the remote address.
std::string socksFarHost() const
Returns the port for the socks far server.
bool resolved() const
Returns true after update() has been called.
std::string service() const
Returns the remote service name, as passed in to the constructor.
unsigned int socksFarPort() const
Returns the port number for the socks far server.
int family() const
Returns the preferred name resolution address family, or AF_UNSPEC.
Location(const std::string &host, const std::string &service, int family=AF_UNSPEC)
Constructor taking a host/service string.
void resolveTrivially()
If host() and service() are already in address format then do a trivial update() so that the location...
std::string host() const
Returns the remote host name, as passed in to the constructor.
G::EpochTime updateTime() const
Returns the time of the last update() or zero if never update()d.