29 std::string GNet::Local::m_name_override ;
30 bool GNet::Local::m_name_override_set = false ;
40 std::string GNet::Local::resolvedHostname()
43 if( !location.resolved() )
49 return location.name() ;
54 return m_name_override_set ? m_name_override : resolvedHostname() ;
59 m_name_override = name_override ;
60 m_name_override_set = true ;
65 return canonicalName().empty() ?
hostname() : canonicalName() ;
77 if( address.
family() == Address::Family::ipv6() )
78 return address.
isLocal( reason ) ;
81 typedef std::vector<Address> List ;
83 static bool done = false ;
91 for( List::iterator p = list.begin() ; p != list.end() ; ++p )
93 if( (*p).sameHostPart(address) )
98 std::stringstream ss ;
105 ss << address.
hostPartString() <<
" is not a loopback address or " ;
106 const char * sep =
"" ;
107 for( List::iterator p = list.begin() ; p != list.end() ; ++p , sep =
" or " )
109 ss << sep << (*p).hostPartString() ;
Family family() const
Returns the address family.
static std::string canonicalName()
Returns the canonical network name assiciated with hostname().
static std::string hostname()
Returns the local hostname.
The GNet::Address class encapsulates a TCP/UDP transport address.
bool isLoopback() const
Returns true if this is a loopback address.
std::string hostname()
Returns the hostname.
static std::string name()
Returns canonicalName(), or hostname() if canonicalName() is the empty string.
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.
std::string hostPartString() const
Returns a string which represents the network address for debugging and diagnostics purposes...
static bool isLocal(const Address &, std::string &reason)
Returns true if the given address appears to be associated with the local host, or a helpful error me...
bool isLocal(std::string &reason) const
Returns true if this seems to be a local address.
static std::string resolve(Location &)
Does syncronous name resolution.