SocketAddr Class Reference
A socket address holder.
More...
#include <yateclass.h>
List of all members.
Detailed Description
A socket address holder.
Wrapper class to keep a socket address
Constructor & Destructor Documentation
Default constructor of an empty address
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 |
Destructor that frees and zeroes out everything
Member Function Documentation
struct sockaddr* address |
( |
|
) |
const [inline, read] |
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
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] |
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
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
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: