Yate
|
A socket address holder. More...
#include <yateclass.h>
Public Member Functions | |
SocketAddr () | |
SocketAddr (const SocketAddr &value) | |
SocketAddr (int family) | |
SocketAddr (const struct sockaddr *addr, socklen_t len=0) | |
virtual | ~SocketAddr () |
SocketAddr & | operator= (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 String & | host () 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 |
A socket address holder.
Wrapper class to keep a socket address
SocketAddr | ( | ) | [inline] |
Default constructor of an empty address
SocketAddr | ( | const SocketAddr & | value | ) | [inline] |
Copy constructor
value | Address to copy |
References SocketAddr::address(), and SocketAddr::length().
SocketAddr | ( | int | family | ) |
Constructor of a null address
family | Family of the address to create |
SocketAddr | ( | const struct sockaddr * | addr, |
socklen_t | len = 0 |
||
) |
Constructor that stores a copy of an address
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
struct sockaddr* address | ( | ) | const [inline, read] |
Get the contained socket address
Referenced by Socket::bind(), Socket::connect(), SocketAddr::operator=(), Socket::sendTo(), and SocketAddr::SocketAddr().
bool assign | ( | int | family | ) |
Assigns an empty address of a specific type
family | Family of the address to create |
void assign | ( | const struct sockaddr * | addr, |
socklen_t | len = 0 |
||
) |
Assigns a new address
addr | Pointer to the address to store |
len | Length of the stored address, zero to use default |
void clear | ( | ) |
Clears up the address, frees the memory
int family | ( | ) | const [inline] |
Get the family of the stored address
virtual bool host | ( | const String & | name | ) | [virtual] |
Set the hostname of this address
socklen_t length | ( | ) | const [inline] |
Get the length of the 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
remote | Remote address to reach |
bool null | ( | ) | const [inline] |
Check if a null address is held
bool operator!= | ( | const SocketAddr & | other | ) | const [inline] |
Inequality comparation operator
other | Address to compare to |
SocketAddr& operator= | ( | const SocketAddr & | value | ) | [inline] |
Assignment operator
value | Address to copy |
References SocketAddr::address(), and SocketAddr::length().
bool operator== | ( | const SocketAddr & | other | ) | const |
Equality comparation operator
other | Address to compare to |
bool port | ( | int | newport | ) |
Set the port of the stored address (if supported)
newport | Port number to set in the socket address |
int port | ( | ) | const |
Get the port of the stored address (if supported)
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
family | Family of the address to check |
bool valid | ( | ) | const [inline] |
Check if a non-null address is held