A generic socket address class. More...
#include <socket.h>
Public Member Functions | |
address (int family, const char *address, int type=SOCK_STREAM, int protocol=0) | |
Construct a socket address. | |
address (Socket &socket, const char *hostname, const char *service=NULL) | |
Construct a socket address for an existing socket. | |
address (socket_t socket, const char *hostname, const char *service=NULL) | |
Construct a socket address for a socket descriptor. | |
address (const char *hostname, unsigned service=0, int family=AF_INET) | |
Construct a socket address from host and service. | |
address () | |
Construct an empty address. | |
address (const address &reference) | |
Copy constructor. | |
~address () | |
Destroy address. | |
struct sockaddr * | getAddr (void) |
Get the first socket address in our address list. | |
struct sockaddr * | get (int family) |
Get the first socket address of specified family from our list. | |
int | getfamily (void) |
Get the family of a socket address by first entry. | |
struct sockaddr * | find (struct sockaddr *addr) |
Find a specific socket address in our address list. | |
struct addrinfo * | getList (void) |
Get the full socket address list from the object. | |
operator struct addrinfo * () | |
Get the full socket address list by casted reference. | |
struct addrinfo * | operator* () |
Return the full socket address list by pointer reference. | |
operator bool () | |
Test if the address list is valid. | |
bool | operator! () |
Test if we have no address list. | |
operator struct sockaddr * () | |
Get the first socket address by casted reference. | |
void | clear (void) |
Clear current object. | |
void | set (const char *hostname, const char *service=NULL, int family=0, int type=SOCK_STREAM) |
Set the host addresses to form a new list. | |
void | add (const char *hostname, const char *service=NULL, int family=0, int type=SOCK_STREAM) |
Append additional host addresses to our list. | |
void | set (int family, const char *address, int type=SOCK_STREAM, int protocol=0) |
Set an entry for host binding. | |
void | add (sockaddr *address) |
Add an individual socket address to our address list. | |
bool | remove (struct sockaddr *address) |
Remove an individual socket address from our address list. | |
bool | insert (struct sockaddr *address) |
Insert an individual socket address to our address list only if unique. | |
unsigned | insert (struct addrinfo *address, int family=0) |
Insert unique members from another socket address list to ours. | |
unsigned | remove (struct addrinfo *address, int family=0) |
Remove members from another socket address list from ours. | |
void | copy (const struct addrinfo *address) |
Copy an existing addrinfo into our object. | |
void | set (struct sockaddr *address) |
Set an individual socket address for our address list. | |
void | set (const char *hostname, unsigned service=0, int family=AF_INET) |
Set a socket address from host and service. | |
Static Public Member Functions | |
static struct sockaddr * | dup (struct sockaddr *address) |
Duplicate a socket address. | |
static struct sockaddr_in * | ipv4 (struct sockaddr *address) |
Convert address object into ipv4 address. | |
Protected Attributes | |
struct addrinfo * | list |
A generic socket address class.
This class uses the addrinfo list to store socket multiple addresses in a protocol and family independent manner. Hence, this address class can be used for ipv4 and ipv6 sockets, for assigning connections to multiple hosts, etc. The address class will call the resolver when passed host names.
Definition at line 307 of file socket.h.
ucc::Socket::address::address | ( | int | family, | |
const char * | address, | |||
int | type = SOCK_STREAM , |
|||
int | protocol = 0 | |||
) |
ucc::Socket::address::address | ( | Socket & | socket, | |
const char * | hostname, | |||
const char * | service = NULL | |||
) |
ucc::Socket::address::address | ( | socket_t | socket, | |
const char * | hostname, | |||
const char * | service = NULL | |||
) |
ucc::Socket::address::address | ( | const char * | hostname, | |
unsigned | service = 0 , |
|||
int | family = AF_INET | |||
) |
ucc::Socket::address::address | ( | const address & | reference | ) |
Copy constructor.
reference | to object to copy from. |
ucc::Socket::address::~address | ( | ) |
Destroy address.
Deallocate addrinfo structure.
void ucc::Socket::address::add | ( | sockaddr * | address | ) |
void ucc::Socket::address::add | ( | const char * | hostname, | |
const char * | service = NULL , |
|||
int | family = 0 , |
|||
int | type = SOCK_STREAM | |||
) |
Append additional host addresses to our list.
hostname | or address to resolve. | |
service | name or port number, or NULL if not used. | |
family | of hostname. | |
type | of socket. |
void ucc::Socket::address::copy | ( | const struct addrinfo * | address | ) |
Copy an existing addrinfo into our object.
This is also used to support the copy constructor.
address | list to copy from. |
static struct sockaddr* ucc::Socket::address::dup | ( | struct sockaddr * | address | ) | [static, read] |
struct sockaddr* ucc::Socket::address::find | ( | struct sockaddr * | addr | ) | [read] |
struct sockaddr* ucc::Socket::address::get | ( | int | family | ) | [read] |
struct sockaddr* ucc::Socket::address::getAddr | ( | void | ) | [read] |
int ucc::Socket::address::getfamily | ( | void | ) |
struct addrinfo* ucc::Socket::address::getList | ( | void | ) | [inline, read] |
unsigned ucc::Socket::address::insert | ( | struct addrinfo * | address, | |
int | family = 0 | |||
) |
bool ucc::Socket::address::insert | ( | struct sockaddr * | address | ) |
static struct sockaddr_in* ucc::Socket::address::ipv4 | ( | struct sockaddr * | address | ) | [static, read] |
ucc::Socket::address::operator bool | ( | ) | [inline] |
ucc::Socket::address::operator struct addrinfo * | ( | ) | [inline] |
ucc::Socket::address::operator struct sockaddr * | ( | ) | [inline] |
bool ucc::Socket::address::operator! | ( | ) | [inline] |
struct addrinfo* ucc::Socket::address::operator* | ( | ) | [inline, read] |
unsigned ucc::Socket::address::remove | ( | struct addrinfo * | address, | |
int | family = 0 | |||
) |
bool ucc::Socket::address::remove | ( | struct sockaddr * | address | ) |
void ucc::Socket::address::set | ( | const char * | hostname, | |
unsigned | service = 0 , |
|||
int | family = AF_INET | |||
) |
void ucc::Socket::address::set | ( | struct sockaddr * | address | ) |
void ucc::Socket::address::set | ( | int | family, | |
const char * | address, | |||
int | type = SOCK_STREAM , |
|||
int | protocol = 0 | |||
) |
void ucc::Socket::address::set | ( | const char * | hostname, | |
const char * | service = NULL , |
|||
int | family = 0 , |
|||
int | type = SOCK_STREAM | |||
) |
Set the host addresses to form a new list.
hostname | or address to resolve. | |
service | name or port number, or NULL if not used. | |
family | of hostname. | |
type | of socket. |