SocketAddr Class Reference

A socket address holder. More...

#include <yateclass.h>

Inheritance diagram for SocketAddr:
GenObject

List of all members.

Public Member Functions

 SocketAddr ()
 SocketAddr (const SocketAddr &value)
 SocketAddr (int family)
 SocketAddr (const struct sockaddr *addr, socklen_t len=0)
virtual ~SocketAddr ()
SocketAddroperator= (const SocketAddr &value)
bool operator== (const SocketAddr &other) const
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)
bool valid () const
bool null () const
int family () const
const Stringhost () const
virtual bool host (const String &name)
int port () const
bool port (int newport)
struct sockaddr * address () const
socklen_t length () const

Static Public Member Functions

static bool supports (int family)

Protected Member Functions

virtual void stringify ()

Protected Attributes

struct sockaddr * m_address
socklen_t m_length
String m_host

Detailed Description

A socket address holder.

Wrapper class to keep a socket address


Constructor & Destructor Documentation

SocketAddr (  )  [inline]

Default constructor of an empty address

SocketAddr ( const SocketAddr value  )  [inline]

Copy constructor

Parameters:
value Address to copy

References SocketAddr::address(), and SocketAddr::length().

SocketAddr ( int  family  ) 

Constructor of a null address

Parameters:
family Family of the address to create
SocketAddr ( const struct sockaddr *  addr,
socklen_t  len = 0 
)

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
virtual ~SocketAddr (  )  [virtual]

Destructor that frees and zeroes out everything


Member Function Documentation

struct sockaddr* address (  )  const [inline, read]

Get the contained socket address

Returns:
A pointer to the socket address

Referenced by Socket::bind(), Socket::connect(), SocketAddr::operator=(), Socket::sendTo(), and SocketAddr::SocketAddr().

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

Assigns a new address

Parameters:
addr Pointer to the address to store
len Length of the stored address, zero to use default
bool assign ( int  family  ) 

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 clear (  ) 

Clears up the address, frees the memory

int family (  )  const [inline]

Get the family of the stored address

Returns:
Address family of the stored address or zero (AF_UNSPEC)
virtual bool host ( const String name  )  [virtual]

Set the hostname of this address

Returns:
True if new host set, false if name could not be parsed
const String& host (  )  const [inline]

Get the host of this address

Returns:
Host name as String
socklen_t length (  )  const [inline]

Get the length of the address

Returns:
Length of the stored address

Referenced by Socket::bind(), Socket::connect(), SocketAddr::operator=(), Socket::sendTo(), and SocketAddr::SocketAddr().

bool local ( const SocketAddr remote  ) 

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
bool null (  )  const [inline]

Check if a null address is held

Returns:
True if a null address is held
bool operator!= ( const SocketAddr other  )  const [inline]

Inequality comparation operator

Parameters:
other Address to compare to
Returns:
True if the addresses are different
SocketAddr& operator= ( const SocketAddr value  )  [inline]

Assignment operator

Parameters:
value Address to copy

References SocketAddr::address(), and SocketAddr::length().

bool operator== ( const SocketAddr other  )  const

Equality comparation operator

Parameters:
other Address to compare to
Returns:
True if the addresses are equal
bool port ( int  newport  ) 

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
int port (  )  const

Get the port of the stored address (if supported)

Returns:
Port number of the socket address or zero
virtual void stringify (  )  [protected, virtual]

Convert the host address to a String stored in m_host

static bool supports ( int  family  )  [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
bool valid (  )  const [inline]

Check if a non-null address is held

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

The documentation for this class was generated from the following file:
Generated on Thu Apr 8 18:19:41 2010 for Yate by  doxygen 1.6.3