21#ifndef G_NET_LOCATION_H
22#define G_NET_LOCATION_H
72 G_EXCEPTION( InvalidFormat ,
tx(
"invalid host:service format") )
73 G_EXCEPTION( InvalidFamily ,
tx(
"invalid address family") )
75 explicit Location(
const std::string & spec ,
int family = AF_UNSPEC ) ;
87 static Location socks(
const std::string & socks_server ,
const std::string & far_server ) ;
91 std::string
host()
const ;
144 static std::string head(
const std::string & ) ;
145 static std::string tail(
const std::string & ) ;
146 static bool socksified(
const std::string & , std::string & , std::string & ) ;
147 static std::string sockless(
const std::string & ) ;
151 std::string m_service ;
152 bool m_address_valid ;
157 std::string m_socks_far_host ;
158 std::string m_socks_far_port ;
163 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 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.
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.
void update(const Address &address)
Updates the address, typically after doing a name lookup on host() and service().
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.
constexpr const char * tx(const char *p) noexcept
A briefer alternative to G::gettext_noop().