EpcTools
An event based multi-threaded C++ development framework.
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 (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...
 
struct sockaddr * getSockAddr ()
 Retrieves a sockaddr pointer 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= (UShort port)
 Assigns a port value (allowing IPADDR_ANY). More...
 
Family getFamily () const
 Retrieves the address family for this address. More...
 
struct sockaddr_in & getInet ()
 Retrieves a reference to this address as an IPv4 address. More...
 
struct sockaddr_in6 & getInet6 ()
 Retrieves a reference to this address as an IPv6 address. More...
 
AddresssetAddress (cpStr addr, UShort port)
 Assigns the socket address. More...
 
AddresssetAddress (UShort port)
 Assigns the socket address. More...
 
Addressclear ()
 Clears this address. More...
 

Detailed Description

Encapsulates a sockaddr_storage structure that represents a socket address.

Constructor & Destructor Documentation

◆ Address() [1/5]

ESocket::Address::Address ( )
inline

Default constructor.

◆ Address() [2/5]

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

Class constructor.

Parameters
addrthe IP address string (IPv4 or IPv6).
portthe IP port.

◆ Address() [3/5]

ESocket::Address::Address ( struct sockaddr_in &  addr)
inline

Class constructor.

Parameters
addrthe IPv4 socket address.

◆ Address() [4/5]

ESocket::Address::Address ( struct sockaddr_in6 &  addr)
inline

Class constructor.

Parameters
addrthe IPv6 socket address.

◆ Address() [5/5]

ESocket::Address::Address ( const Address addr)
inline

Copy constructor.

Parameters
addrthe Address object to copy.

Member Function Documentation

◆ clear()

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

Clears this address.

Returns
a reference to this address object.

◆ getAddress()

EString ESocket::Address::getAddress ( ) const
inline

Retrieves the printable IP address.

Returns
the printable IP address.

◆ getFamily()

Family ESocket::Address::getFamily ( ) const
inline

Retrieves the address family for this address.

Returns
the address family for this address.

◆ getInet()

struct sockaddr_in& ESocket::Address::getInet ( )
inline

Retrieves a reference to this address as an IPv4 address.

Returns
a reference to this address as an IPv4 address.

◆ getInet6()

struct sockaddr_in6& ESocket::Address::getInet6 ( )
inline

Retrieves a reference to this address as an IPv6 address.

Returns
a reference to this address as an IPv6 address.

◆ getPort()

UShort ESocket::Address::getPort ( ) const
inline

Retrievs the port.

Returns
the port.

◆ getSockAddr()

struct sockaddr* ESocket::Address::getSockAddr ( )
inline

Retrieves a sockaddr pointer to the socket address.

Returns
a sockaddr pointer to the socket address.

◆ getSockAddrLen()

socklen_t ESocket::Address::getSockAddrLen ( ) const
inline

retrieves the length of the current socket address.

Returns
the length of the current socket address.

◆ operator EString()

ESocket::Address::operator EString ( ) const
inline

Extracts a string object with the printable IP address.

Returns
EString representation of the IP address.

◆ operator UShort()

ESocket::Address::operator UShort ( ) const
inline

Extracts the port.

Returns
the port.

◆ operator=() [1/2]

Address& ESocket::Address::operator= ( const Address addr)
inline

Assignment operator.

Parameters
addrthe Address object to copy.
Returns
a reference to this Address object.

◆ operator=() [2/2]

Address& ESocket::Address::operator= ( UShort  port)
inline

Assigns a port value (allowing IPADDR_ANY).

Parameters
portthe port.
Returns
a reference to this Address object.

◆ setAddress() [1/2]

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.

◆ setAddress() [2/2]

Address& ESocket::Address::setAddress ( UShort  port)
inline

Assigns the socket address.

Parameters
portthe port.
Returns
a reference to this address object.

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