34 class AddressStorage ;
36 class AddressStorageImp ;
52 G_EXCEPTION( BadFamily ,
"unsupported address family" ) ;
53 G_EXCEPTION( BadString ,
"invalid ip address string" ) ;
70 Address(
const sockaddr * addr , socklen_t len ) ;
86 Address(
const hostent & h ,
const servent & s ) ;
92 explicit Address(
const servent & s ) ;
111 explicit Address(
const std::string & display_string ) ;
119 Address(
const std::string & ip ,
unsigned int port ) ;
144 const sockaddr *
address()
const ;
156 std::string
displayString(
bool with_port =
true ,
bool with_scope_id =
false )
const ;
164 unsigned int port()
const;
170 unsigned long scopeId(
unsigned long default_ = 0UL )
const ;
175 static bool validPort(
unsigned int n ) ;
180 static bool validString(
const std::string & display_string , std::string * reason = NULL ) ;
191 bool isLocal( std::string & reason )
const ;
196 bool isLocal( std::string & reason ,
const Address & local_hint )
const ;
215 void setHost(
const hostent & ) ;
242 const sockaddr *
p()
const ;
245 socklen_t
n()
const ;
G::Strings wildcards() const
Returns an ordered list of wildcard strings that match this address.
A pimple-pattern implementation class for GNet::Address.
static Address broadcastAddress(unsigned int port)
Returns a broadcast address.
static int defaultDomain()
Returns the default address 'domain', eg. PF_INET.
static Address localhost(unsigned int port=0U)
Returns a localhost ("loopback") address.
std::list< std::string > Strings
A std::list of std::strings.
A helper class for calling getsockname() and getpeername() and hiding the definition of sockaddr_stor...
The Address class encapsulates an IP transport address.
socklen_t * p2()
Returns the length pointer for getsockname()/getpeername() to write into.
sockaddr * p1()
Returns the sockaddr pointer for getsockname()/getpeername() to write into.
static Address invalidAddress()
Returns an invalid address.
A pimple-pattern implementation class for GNet::AddressStorage.
const sockaddr * address() const
Returns the sockaddr address.
std::string hostString() const
Returns a string which represents the host part of the address for debugging and diagnostics purposes...
unsigned int port() const
Returns port part of address.
bool operator==(const Address &) const
Comparison operator.
const sockaddr * p() const
Returns the pointer.
Address(const Address &addr)
Copy constructor.
AddressStorage()
Default constructor.
std::string displayString(bool with_port=true, bool with_scope_id=false) const
Returns a string which represents the address for debugging and diagnostics purposes.
socklen_t length() const
Returns the size of the sockaddr address.
bool sameHost(const Address &other) const
Returns true if the two addresses have the same host part (ie.
unsigned long scopeId(unsigned long default_=0UL) const
Returns the scope-id.
int domain() const
Returns the address 'domain', eg. PF_INET.
~AddressStorage()
Destructor.
static bool validPort(unsigned int n)
Returns true if the port number is within the valid range.
bool isLocal(std::string &reason) const
Returns true if the address is definitely local.
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
An overload discriminator class for GNet::Address.
An overload discriminator class for GNet::Address.
void operator=(const Address &addr)
Assignment operator.
static bool validString(const std::string &display_string, std::string *reason=NULL)
Returns true if the display string is valid.
void setPort(unsigned int port)
Sets the port number.
socklen_t n() const
Returns the length.