libassa 3.5.1
|
#include <INETAddress.h>
Public Types | |
enum | Protocol { TCP , UDP } |
![]() | |
enum | addr_state_t { goodbit =0 , badbit =1 } |
State bits. More... | |
typedef int | addrstate |
Public Member Functions | |
INETAddress () | |
Default constructor. | |
INETAddress (struct in_addr *haddr_, int port_) | |
Constructor to create address on a client side given address in struct in_addr and integer port number. | |
INETAddress (const char *host_, int port_) | |
Constructor to create address on the client side given host name and integer port number. | |
INETAddress (const char *host_, const char *service_, Protocol protocol_=TCP) | |
Constructor to create address on the client side given host name and service name (as in /etc/services) and optionally protocol type. | |
INETAddress (int port_) | |
Constructor to create address of listening socket on a server side from integer port number. | |
INETAddress (const char *address_, Protocol protocol_=TCP) | |
Constructor to create address both client- and server-side addresses. | |
INETAddress (SA_IN *address_) | |
Copy constructor. | |
INETAddress (SA *address_) | |
Copy constructor from base address. | |
~INETAddress () | |
Destructor. | |
const int | getLength () const |
Return address length. | |
SA * | getAddress () const |
Get hold of address structure. | |
string | getHostName () |
Return host name. | |
int | getPort () const |
Return port. | |
void | dump () |
Dump the address content to log file. | |
![]() | |
Address () | |
Constructor. | |
virtual | ~Address () |
Destructor. | |
bool | good () const |
Valid address is constructed. | |
bool | bad () const |
Indicates whether there was error during address construction process i.e. | |
operator void * () const | |
Conversion to void * (or bool) for testing where bool is required (in conditional statements). | |
bool | operator! () const |
Alias to bad (). | |
Static Public Member Functions | |
static string | get_fully_qualified_domain_name (vector< string > &aliases_) |
Return fully-qualified host name. | |
Private Member Functions | |
void | createHostPort (const char *host_, int port_) |
Makes socket address out of host name and port. | |
int | getServiceByName (string serv_, Protocol prot_=TCP) |
Lookup port by its service name found in /etc/services. | |
void | init () |
Perform initialization common to all ctors. | |
Private Attributes | |
SA_IN | m_address |
Internet address structure sockaddr_in. | |
Static Private Attributes | |
static string | m_fqdn_cache |
Cached fully-qualified domain name. | |
Additional Inherited Members | |
![]() | |
void | setstate (addrstate flag_) |
Set state of the Address object. | |
Definition at line 27 of file INETAddress.h.
Enumerator | |
---|---|
TCP | TCP protocol. |
UDP | UDP protocol. |
Definition at line 30 of file INETAddress.h.
INETAddress::INETAddress | ( | ) |
Default constructor.
Definition at line 38 of file INETAddress.cpp.
References init().
Constructor to create address on a client side given address in struct in_addr and integer port number.
haddr_ | XDR-encoded server host address structure |
port_ | Server listening port |
Definition at line 89 of file INETAddress.cpp.
Constructor to create address on the client side given host name and integer port number.
host_ | server host name |
port_ | port server listens on |
Definition at line 45 of file INETAddress.cpp.
References createHostPort(), and init().
Constructor to create address on the client side given host name and service name (as in /etc/services) and optionally protocol type.
host_ | Server host name |
service_ | Server listening port |
protocol_ | protocol: TCP (default) or UDP |
Definition at line 53 of file INETAddress.cpp.
References createHostPort(), getServiceByName(), and init().
INETAddress::INETAddress | ( | int | port_ | ) |
Constructor to create address of listening socket on a server side from integer port number.
port_ | port to use |
Definition at line 62 of file INETAddress.cpp.
References createHostPort(), and init().
Constructor to create address both client- and server-side addresses.
Address is derived from the character string address_ which can be specified in one of the following formats:
Formats:
If host is omitted, wildcard (INADDR_ANY) address is assumed. This essentially creates an address of the server's listening socket.
To create client-side address, use localhost (or host) name instead.
service entry can be either port name as listed in /etc/services or integer port value.
address_ | Address string. |
protocol_ | Protocol: TCP (by default) or UDP. |
Definition at line 100 of file INETAddress.cpp.
References createHostPort(), getServiceByName(), and init().
INETAddress::INETAddress | ( | SA_IN * | address_ | ) |
INETAddress::INETAddress | ( | SA * | address_ | ) |
|
inline |
Destructor.
Definition at line 102 of file INETAddress.h.
Makes socket address out of host name and port.
Host name is either a host name, or an IPv4 address in standard dot notation, or an IPv6 address in colon (and possibly dot) notation. If it is in dot notation, no lookup is performed.
Otherwise, lookup is performed by consulting name resolution services in order specified in in /etc/host.conf file (named(8) first, then /etc/hosts, and so on).
Port port_ must be supplied in network-independent byte order. If host_ is an empty string, then local host name is assumed.
If failed, state of the object is set to bad, and errno indicates the error occured.
Definition at line 158 of file INETAddress.cpp.
References ASSA::ASSAERR, ASSA::Address::badbit, EL, m_address, and ASSA::Address::setstate().
Referenced by INETAddress(), INETAddress(), INETAddress(), and INETAddress().
|
virtual |
Dump the address content to log file.
Reimplemented from ASSA::Address.
Definition at line 205 of file INETAddress.cpp.
References ASSA::ADDRESS, DL, ASSA::Address::dump(), getHostName(), getPort(), and m_address.
|
static |
Return fully-qualified host name.
Note that a host can have name aliases. If it does, they are returned via argument.
aliases_ | List of host aliases, if any |
Definition at line 230 of file INETAddress.cpp.
References ASSA::ADDRESS, EL, and m_fqdn_cache.
|
inlinevirtual |
Get hold of address structure.
Implements ASSA::Address.
Definition at line 110 of file INETAddress.h.
References m_address.
string INETAddress::getHostName | ( | ) |
Return host name.
Definition at line 184 of file INETAddress.cpp.
References ASSA::ASSAERR, ASSA::Address::badbit, EL, m_address, and ASSA::Address::setstate().
Referenced by dump().
Return address length.
Implements ASSA::Address.
Definition at line 107 of file INETAddress.h.
References m_address.
|
inline |
Return port.
Definition at line 116 of file INETAddress.h.
References m_address.
Referenced by dump().
Lookup port by its service name found in /etc/services.
serv_ is either service name, or integer port number. If it is integer port number, it is converted to the network-independent byte order and no lookup is performed.
serv_ | Service name. |
prot_ | Protocol: tcp (default) or udp. |
Definition at line 137 of file INETAddress.cpp.
References ASSA::Address::badbit, ASSA::Address::setstate(), and TCP.
Referenced by INETAddress(), and INETAddress().
|
private |
Perform initialization common to all ctors.
Definition at line 32 of file INETAddress.cpp.
References m_address.
Referenced by INETAddress(), INETAddress(), INETAddress(), INETAddress(), INETAddress(), INETAddress(), INETAddress(), and INETAddress().
|
private |
Internet address structure sockaddr_in.
Definition at line 172 of file INETAddress.h.
Referenced by createHostPort(), dump(), getAddress(), getHostName(), getLength(), getPort(), INETAddress(), INETAddress(), INETAddress(), and init().
|
staticprivate |
Cached fully-qualified domain name.
Definition at line 168 of file INETAddress.h.
Referenced by get_fully_qualified_domain_name().