22 #ifndef G_NET_ADDRESS4__H
23 #define G_NET_ADDRESS4__H
40 typedef sockaddr general_type ;
41 typedef sockaddr_in specific_type ;
42 typedef sockaddr storage_type ;
44 { specific_type specific ; general_type general ; storage_type storage ; } ;
47 explicit Address4(
const std::string & ) ;
48 Address4(
const std::string & ,
const std::string & ) ;
49 Address4(
const std::string & ,
unsigned int ) ;
50 Address4(
unsigned int port ,
int ) ;
51 Address4(
const sockaddr * addr , socklen_t len ) ;
55 static unsigned short family() ;
56 const sockaddr * address()
const ;
57 sockaddr * address() ;
58 static socklen_t length() ;
60 unsigned int port()
const ;
61 void setPort(
unsigned int port ) ;
63 static bool validString(
const std::string & , std::string * =
nullptr ) ;
64 static bool validStrings(
const std::string & ,
const std::string & , std::string * =
nullptr ) ;
65 static bool validPort(
unsigned int port ) ;
66 static bool validData(
const sockaddr * addr , socklen_t len ) ;
68 bool same(
const Address4 & other )
const ;
69 bool sameHostPart(
const Address4 & other )
const ;
70 bool isLoopback()
const ;
71 bool isLocal( std::string & )
const ;
73 std::string displayString()
const ;
74 std::string hostPartString()
const ;
76 static bool format( std::string ) ;
80 static const char * setAddress(
union_type & ,
const std::string & ) ;
81 static const char * setHostAddress(
union_type & ,
const std::string & ) ;
82 static const char * setPort(
union_type & ,
unsigned int ) ;
83 static const char * setPort(
union_type & ,
const std::string & ) ;
84 static bool sameAddr( const ::in_addr & a , const ::in_addr & b ) ;
85 static void add(
G::StringArray & ,
const std::string & ,
unsigned int ,
const char * ) ;
86 static void add(
G::StringArray & ,
const std::string & ,
const char * ) ;
Used by GNet::Address4 to cast between sockaddr and sockaddr_in.
std::vector< std::string > StringArray
A std::vector of std::strings.
A 'sockaddr' wrapper class for IPv4 addresses.