EpcTools
An event based multi-threaded C++ development framework.
Public Member Functions | Static Public Member Functions | List of all members
ESocket::Address Class Reference

Encapsulates a sockaddr_storage structure that represents a socket address. More...

#include <esocket.h>

Public Member Functions

 Address ()
 Default constructor. More...
 
 Address (cpStr addr, UShort port)
 Class constructor. More...
 
 Address (const struct in_addr &addr, UShort port)
 Class constructor. More...
 
 Address (const struct in6_addr &addr, UShort port)
 Class constructor. More...
 
 Address (struct sockaddr_in &addr)
 Class constructor. More...
 
 Address (struct sockaddr_in6 &addr)
 Class constructor. More...
 
 Address (const Address &addr)
 Copy constructor. More...
 
 operator EString () const
 Extracts a string object with the printable IP address. More...
 
 operator UShort () const
 Extracts the port. More...
 
EString getAddress () const
 Retrieves the printable IP address. More...
 
UShort getPort () const
 Retrievs the port. More...
 
const struct sockaddr_storage & getSockAddrStorage () const
 Retrieves a sockaddr pointer to the socket address. More...
 
struct sockaddr * getSockAddr () const
 Retrieves a sockaddr_storage reference to the socket address. More...
 
socklen_t getSockAddrLen () const
 retrieves the length of the current socket address. More...
 
Addressoperator= (const Address &addr)
 Assignment operator. More...
 
Addressoperator= (const sockaddr_in &addr)
 Assignment operator. More...
 
Addressoperator= (const sockaddr_in6 &addr)
 Assignment operator. More...
 
Addressoperator= (UShort port)
 Assigns a port value (allowing IPADDR_ANY). More...
 
Family getFamily () const
 Retrieves the address family for this address. More...
 
const struct sockaddr_storage & getStorage () const
 Retrieves the sockaddr_storage. More...
 
const struct sockaddr_in & getInet () const
 Retrieves a reference to this address as an IPv4 address. More...
 
const struct sockaddr_in6 & getInet6 () const
 Retrieves a reference to this address as an IPv6 address. More...
 
AddresssetAddress (cpStr addr, UShort port)
 Assigns the socket address. More...
 
AddresssetAddress (const struct in_addr &addr, UShort port)
 Assigns the IPv4 socket address. More...
 
AddresssetAddress (const struct in6_addr &addr, UShort port)
 Assigns the IPv6 socket address. More...
 
AddresssetAddress (UShort port, Family fam=Family::INET6)
 Assigns the socket address. More...
 
AddresssetAddress (const sockaddr_in &addr)
 
AddresssetAddress (const sockaddr_in6 &addr)
 
Addressclear ()
 Clears this address. More...
 

Static Public Member Functions

static Family getFamily (cpStr addr)
 Determines the address family. More...
 

Detailed Description

Encapsulates a sockaddr_storage structure that represents a socket address.

Constructor & Destructor Documentation

ESocket::Address::Address ( )
inline

Default constructor.

ESocket::Address::Address ( cpStr  addr,
UShort  port 
)
inline

Class constructor.

Parameters
addrthe IP address string (IPv4 or IPv6).
portthe IP port.
ESocket::Address::Address ( const struct in_addr &  addr,
UShort  port 
)
inline

Class constructor.

Parameters
addrthe IPv4 address.
portthe IP port.
ESocket::Address::Address ( const struct in6_addr &  addr,
UShort  port 
)
inline

Class constructor.

Parameters
addrthe IP IPv6 address.
portthe IP port.
ESocket::Address::Address ( struct sockaddr_in &  addr)
inline

Class constructor.

Parameters
addrthe IPv4 socket address.
ESocket::Address::Address ( struct sockaddr_in6 &  addr)
inline

Class constructor.

Parameters
addrthe IPv6 socket address.
ESocket::Address::Address ( const Address addr)
inline

Copy constructor.

Parameters
addrthe Address object to copy.

Member Function Documentation

Address& ESocket::Address::clear ( )
inline

Clears this address.

Returns
a reference to this address object.
EString ESocket::Address::getAddress ( ) const
inline

Retrieves the printable IP address.

Returns
the printable IP address.
Family ESocket::Address::getFamily ( ) const
inline

Retrieves the address family for this address.

Returns
the address family for this address.
static Family ESocket::Address::getFamily ( cpStr  addr)
inlinestatic

Determines the address family.

Returns
the address family.
const struct sockaddr_in& ESocket::Address::getInet ( ) const
inline

Retrieves a reference to this address as an IPv4 address.

Returns
a reference to this address as an IPv4 address.
const struct sockaddr_in6& ESocket::Address::getInet6 ( ) const
inline

Retrieves a reference to this address as an IPv6 address.

Returns
a reference to this address as an IPv6 address.
UShort ESocket::Address::getPort ( ) const
inline

Retrievs the port.

Returns
the port.
struct sockaddr* ESocket::Address::getSockAddr ( ) const
inline

Retrieves a sockaddr_storage reference to the socket address.

Returns
a sockaddr_storage reference to the socket address.
socklen_t ESocket::Address::getSockAddrLen ( ) const
inline

retrieves the length of the current socket address.

Returns
the length of the current socket address.
const struct sockaddr_storage& ESocket::Address::getSockAddrStorage ( ) const
inline

Retrieves a sockaddr pointer to the socket address.

Returns
a sockaddr pointer to the socket address.
const struct sockaddr_storage& ESocket::Address::getStorage ( ) const
inline

Retrieves the sockaddr_storage.

Returns
a reference to the sockaddr_storage member.
ESocket::Address::operator EString ( ) const
inline

Extracts a string object with the printable IP address.

Returns
EString representation of the IP address.
ESocket::Address::operator UShort ( ) const
inline

Extracts the port.

Returns
the port.
Address& ESocket::Address::operator= ( const Address addr)
inline

Assignment operator.

Parameters
addrthe Address object to copy.
Returns
a reference to this Address object.
Address& ESocket::Address::operator= ( const sockaddr_in &  addr)
inline

Assignment operator.

Parameters
addrthe IPV4 address object to copy.
Returns
a reference to this Address object.
Address& ESocket::Address::operator= ( const sockaddr_in6 &  addr)
inline

Assignment operator.

Parameters
addrthe IPV6 address object to copy.
Returns
a reference to this Address object.
Address& ESocket::Address::operator= ( UShort  port)
inline

Assigns a port value (allowing IPADDR_ANY).

Parameters
portthe port.
Returns
a reference to this Address object.
Address& ESocket::Address::setAddress ( cpStr  addr,
UShort  port 
)
inline

Assigns the socket address.

Parameters
addrthe IP address.
portthe port.
Returns
a reference to this address object.
Address& ESocket::Address::setAddress ( const struct in_addr &  addr,
UShort  port 
)
inline

Assigns the IPv4 socket address.

Parameters
addrthe IPv4 address.
portthe port.
Returns
a reference to this address object.
Address& ESocket::Address::setAddress ( const struct in6_addr &  addr,
UShort  port 
)
inline

Assigns the IPv6 socket address.

Parameters
addrthe IPv6 address.
portthe port.
Returns
a reference to this address object.
Address& ESocket::Address::setAddress ( UShort  port,
Family  fam = Family::INET6 
)
inline

Assigns the socket address.

Parameters
portthe port.
famthe address family.
Returns
a reference to this address object.
Address& ESocket::Address::setAddress ( const sockaddr_in &  addr)
inline
Address& ESocket::Address::setAddress ( const sockaddr_in6 &  addr)
inline

The documentation for this class was generated from the following file: