21#ifndef G_NET_LOCATION_H
22#define G_NET_LOCATION_H
73 G_EXCEPTION( InvalidFormat ,
"invalid host:service format" ) ;
74 G_EXCEPTION( InvalidFamily ,
"invalid address family" ) ;
76 explicit Location(
const std::string & spec ,
int family = AF_UNSPEC ) ;
88 static Location socks(
const std::string & socks_server ,
const std::string & far_server ) ;
92 std::string
host()
const ;
130 std::string
name()
const ;
151 static std::string head(
const std::string & ) ;
152 static std::string tail(
const std::string & ) ;
153 static bool socksified(
const std::string & , std::string & , std::string & ) ;
154 static std::string sockless(
const std::string & ) ;
158 std::string m_service ;
159 bool m_address_valid ;
162 std::string m_canonical_name ;
165 std::string m_socks_far_host ;
166 std::string m_socks_far_port ;
171 inline std::ostream & operator<<( std::ostream & stream ,
const Location & location )
The GNet::Address class encapsulates a TCP/UDP transport address.
A class that represents the remote target for out-going client connections.
int family() const
Returns the preferred name resolution address family as passed to the constructor.
bool resolved() const
Returns true after update() has been called or resolveTrivially() succeeded.
bool resolveTrivially()
If host() and service() are already in address format then do a trivial update() so that the location...
std::string name() const
Returns the remote canonical name.
std::string displayString() const
Returns a string representation for logging and debug.
std::string socksFarHost() const
Returns the port for the socks far server.
G::SystemTime updateTime() const
Returns the time of the last update() or zero if never update()d.
bool socks() const
Returns true if a socks location.
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().
std::string service() const
Returns the remote service name derived from the constructor parameter.
unsigned int socksFarPort() const
Returns the port number for the socks far server.
Address address() const
Returns the remote address.
std::string host() const
Returns the remote host name derived from the constructor parameter.
Location(const std::string &spec, int family=AF_UNSPEC)
Constructor taking a formatted "host:service" string.
static Location nosocks(const std::string &spec, int family=AF_UNSPEC)
Factory function for a remote location but not allowing the extended syntax for socks.
Represents a unix-epoch time with microsecond resolution.