# class SocketAddr | A socket address holder. More...
Full name | `TelEngine::SocketAddr`
Definition | `#include <yateclass.h>`
Inherits | TelEngine::GenObject [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- inline SocketAddr ()
- inline SocketAddr (const SocketAddr& value)
- explicit SocketAddr (int family)
- SocketAddr (const struct sockaddr* addr, socklen_t len = 0)
- virtual ~SocketAddr ()
- inline SocketAddr& operator= (const SocketAddr& value)
- bool operator== (const SocketAddr& other) const
- inline bool operator!= (const SocketAddr& other) const
- void clear ()
- bool assign (int family)
- void assign (const struct sockaddr* addr, socklen_t len = 0)
- bool local (const SocketAddr& remote)
- inline bool valid () const
- inline bool null () const
- inline int family () const
- inline const String& host () const
- virtual bool host (const String& name)
- int port () const
- bool port (int newport)
- inline struct sockaddr* address () const
- inline socklen_t length () const

#### Public Static Methods

- static bool supports (int family)

#### Protected Methods

- virtual void stringify ()

#### Protected Members

- struct sockaddr* m_address
- socklen_t m_length
- String m_host

## Detailed Description

Wrapper class to keep a socket address

inline SocketAddr () | ### SocketAddr

Default constructor of an empty address

inline SocketAddr (const SocketAddr& value) | ### SocketAddr

Copy constructor

Parameters:

value | Address to copy

explicit SocketAddr (int family) | ### SocketAddr

Constructor of a null address

Parameters:

family | Family of the address to create

SocketAddr (const struct sockaddr* addr, socklen_t len = 0) | ### SocketAddr

Constructor that stores a copy of an address

Parameters:

addr | Pointer to the address to store
len | Length of the stored address, zero to use default

~SocketAddr () | ### ~SocketAddr

[virtual]

Destructor that frees and zeroes out everything

inline SocketAddr& operator= (const SocketAddr& value) | ### operator=

Assignment operator

Parameters:

value | Address to copy

bool operator== (const SocketAddr& other) | ### operator==

[const]

Equality comparation operator

Parameters:

other | Address to compare to

Returns: True if the addresses are equal

inline bool operator!= (const SocketAddr& other) | ### operator!=

[const]

Inequality comparation operator

Parameters:

other | Address to compare to

Returns: True if the addresses are different

void clear () | ### clear

Clears up the address, frees the memory

bool assign (int family) | ### assign

Assigns an empty address of a specific type

Parameters:

family | Family of the address to create

Returns: True if the address family is supported

void assign (const struct sockaddr* addr, socklen_t len = 0) | ### assign

Assigns a new address

Parameters:

addr | Pointer to the address to store
len | Length of the stored address, zero to use default

bool local (const SocketAddr& remote) | ### local

Attempt to guess a local address that will be used to reach a remote one

Parameters:

remote | Remote address to reach

Returns: True if guessed an address, false if failed

inline bool valid () | ### valid

[const]

Check if a non-null address is held

Returns: True if a valid address is held, false if null

inline bool null () | ### null

[const]

Check if a null address is held

Returns: True if a null address is held

inline int family () | ### family

[const]

Get the family of the stored address

Returns: Address family of the stored address or zero (AF_UNSPEC)

inline const String& host () | ### host

[const]

Get the host of this address

Returns: Host name as String

bool host (const String& name) | ### host

[virtual]

Set the hostname of this address

Returns: True if new host set, false if name could not be parsed

int port () | ### port

[const]

Get the port of the stored address (if supported)

Returns: Port number of the socket address or zero

bool port (int newport) | ### port

Set the port of the stored address (if supported)

Parameters:

newport | Port number to set in the socket address

Returns: True if new port set, false if not supported

inline struct sockaddr* address () | ### address

[const]

Get the contained socket address

Returns: A pointer to the socket address

inline socklen_t length () | ### length

[const]

Get the length of the address

Returns: Length of the stored address

bool supports (int family) | ### supports

[static]

Check if an address family is supported by the library

Parameters:

family | Family of the address to check

Returns: True if the address family is supported

void stringify () | ### stringify

[protected virtual]

Convert the host address to a String stored in m_host

struct sockaddr* m_address | ### m_address

[protected]

socklen_t m_length | ### m_length

[protected]

String m_host | ### m_host

[protected]

Generated by: paulc on bussard on Fri Dec 21 16:28:34 2012, using kdoc 2.0a54.