A generic socket base class. More...
#include <socket.h>

Data Structures | |
| class | address |
| A generic socket address class. More... | |
Public Types | |
| typedef void * | set_t |
| External definition of fd_set type. | |
Public Member Functions | |
| int | blocking (bool enable) |
| Set socket blocking I/O mode. | |
| int | broadcast (bool enable) |
| Set socket for unicast mode broadcasts. | |
| void | cancel (void) |
| Cancel pending i/o by shutting down the socket. | |
| int | connectto (struct addrinfo *list) |
| Connect our socket to a remote host from an address list. | |
| int | disconnect (void) |
| Disconnect a connected socket. | |
| int | drop (struct addrinfo *list) |
| Drop socket from multicast group. | |
| virtual ssize_t | get (void *data, size_t number, struct sockaddr_storage *address=NULL) |
| Read data from the socket receive buffer. | |
| int | getError (void) |
| Get socket error code. | |
| unsigned | getPending (void) const |
| Get the number of bytes of data in the socket receive buffer. | |
| virtual ssize_t | gets (char *data, size_t size, timeout_t timeout=Timer::inf) |
| Read a newline of text data from the socket and save in NULL terminated string. | |
| int | gettype (void) |
| Get the type of a socket. | |
| bool | isConnected (void) const |
| Test if socket is connected. | |
| bool | isPending (unsigned value) const |
| See the number of bytes in the receive queue. | |
| int | join (struct addrinfo *list) |
| Join socket to multicast group. | |
| int | keepalive (bool enable) |
| Set socket for keepalive packets. | |
| int | loopback (bool enable) |
| Set loopback to read multicast packets we broadcast. | |
| int | multicast (unsigned ttl=1) |
| Set multicast mode and multicast broadcast range. | |
| int | nodelay (void) const |
| Set nodelay option for tcp socket. | |
| FILE * | open (bool mode=false) |
| Get file handle for reading from a socket object. | |
| operator bool () | |
| Test if socket is valid. | |
| operator socket_t () const | |
| Get the socket descriptor by casting. | |
| bool | operator! () const |
| Test if socket is invalid. | |
| socket_t | operator* () const |
| Get the socket descriptor by pointer reference. | |
| Socket & | operator= (socket_t socket) |
| Assign socket from a socket descriptor. | |
| size_t | peek (void *data, size_t number) const |
| Peek at data waiting in the socket receive buffer. | |
| int | priority (int scheduling) |
| Set packet priority, 0 to 6 unless privileged. | |
| virtual ssize_t | put (const void *data, size_t number, struct sockaddr *address=NULL) |
| Write data to the socket send buffer. | |
| ssize_t | puts (const char *string, struct sockaddr *address) |
| Write a null terminated string to the socket. | |
| ssize_t | puts (const char *string) |
| Write a null terminated string to the socket. | |
| ssize_t | readfrom (void *data, size_t number, struct sockaddr_storage *address=NULL) |
| Read data from the socket receive buffer. | |
| int | recvsize (unsigned size) |
| Set the size of the socket receive buffer. | |
| void | release (void) |
| Shutdown and close the socket. | |
| unsigned | segsize (unsigned size) |
| Set segment size and get mtu of a socket. | |
| int | sendsize (unsigned size) |
| Set the size of the socket send buffer. | |
| int | sendwait (unsigned size) |
| Set the size to wait before sending. | |
| bool | setccid (uint8_t ccid) |
| Set ccid of dccp socket. | |
| void | shutdown (void) |
| Shutdown the socket communication channel. | |
| Socket (const char *address, const char *port, int family=AF_UNSPEC, int type=0, int protocol=0, int backlog=0) | |
| Create a bound socket. | |
| Socket (int family, int type, int protocol=0) | |
| Create an unbound socket of a specific type. | |
| Socket (struct addrinfo *address) | |
| Create and connect a socket to an address from an address list. | |
| Socket (socket_t socket) | |
| Create socket from existing socket descriptor. | |
| Socket (const Socket &existing) | |
| Create socket as duped handle of existing socket. | |
| Socket () | |
| Create a socket object for use. | |
| int | tos (int type) |
| Set the type of service field of outgoing packets. | |
| int | ttl (unsigned char time) |
| Set the time to live before packets expire. | |
| bool | waitPending (timeout_t timeout=0) const |
| Test for pending input data. | |
| bool | waitSending (timeout_t timeout=0) const |
| Test for output data sent. | |
| ssize_t | writeto (const void *data, size_t number, struct sockaddr *address=NULL) |
| Write data to the socket send buffer. | |
| virtual | ~Socket () |
| Shutdown, close, and destroy socket. | |
Static Public Member Functions | |
| static Socket | acceptfrom (Socket &socket, struct sockaddr_storage *address) |
| Accept connection through socket. | |
| static socket_t | acceptfrom (socket_t socket, struct sockaddr_storage *address=NULL) |
| Accept a socket connection from a remote host. | |
| static int | bindto (socket_t socket, struct sockaddr *address) |
| Bind the socket descriptor to a known interface. | |
| static int | bindto (socket_t socket, const char *address, const char *service, int protocol=0) |
| Bind the socket descriptor to a known interface and service port. | |
| static int | blocking (socket_t socket, bool enable) |
| Set socket blocking I/O mode of socket descriptor. | |
| static int | broadcast (socket_t socket, bool enable) |
| Set socket for unicast mode broadcasts on socket descriptor. | |
| static void | cancel (socket_t socket) |
| Cancel pending i/o by shutting down the socket. | |
| static void | clear (socket_t socket, set_t mask) |
| Clear a socket entry in a mask. | |
| static void | clear (set_t mask) |
| Clear a mask, setting all entries to zero. | |
| static void | close (FILE *file) |
| Cleanly close a connected socket descriptor mapped to a file handle. | |
| static void | connectto (Socket &socket, Socket::address &address) |
| Connect a socket. | |
| static int | connectto (socket_t socket, struct addrinfo *list) |
| Connect socket descriptor to a remote host from an address list. | |
| static unsigned | copy (struct sockaddr *target, struct sockaddr *origin) |
| Copy a socket address. | |
| static socket_t | create (Socket::address &address) |
| Create a connected socket for a service. | |
| static socket_t | create (const char *iface, const char *service, int family=AF_UNSPEC, int type=0, int protocol=0, int backlog=0) |
| Create a bound socket for a service. | |
| static socket_t | create (struct addrinfo *address, int type, int protocol) |
| Create a connected socket. | |
| static socket_t | create (int family, int type, int protocol) |
| Create a socket object unbound. | |
| static void | disconnect (Socket &socket) |
| Disconnect a connected socket. | |
| static int | disconnect (socket_t socket) |
| Disconnect a connected socket descriptor. | |
| static int | drop (socket_t socket, struct addrinfo *list) |
| Drop socket descriptor from multicast group. | |
| static bool | equal (struct sockaddr *address1, struct sockaddr *address2) |
| Compare socket addresses. | |
| static bool | equalfrom (struct sockaddr_storage *address1, struct sockaddr_storage *address2) |
| Compare socket addresses. | |
| static bool | equalhost (struct sockaddr *address1, struct sockaddr *address2) |
| Compare socket host addresses. | |
| static bool | equalinet (struct sockaddr_internet *address1, struct sockaddr_internet *address2) |
| Compare socket addresses. | |
| static int | error (void) |
| Return error code of last socket operation,. | |
| static int | error (socket_t socket) |
| Get socket error code of socket descriptor. | |
| static void | family (int query) |
| Set default socket family preference for query options when the socket type is otherwise not specified. | |
| static socklen_t | getaddr (socket_t socket, struct sockaddr_storage *address, const char *hostname, const char *service) |
| Lookup a host name and service address based on the addressing family and socket type of a socket descriptor. | |
| static char * | getaddress (struct sockaddr *address, char *buffer, socklen_t size) |
| Get the hostname of a socket address. | |
| static int | getfamily (struct sockaddr_internet &address) |
| Get the address family of an internet socket address object. | |
| static int | getfamily (struct sockaddr_storage &address) |
| Get the address family of a socket address object. | |
| static int | getfamily (socket_t socket) |
| Get the address family of the socket descriptor. | |
| static struct addrinfo * | gethint (socket_t socket, struct addrinfo *hint) |
| Create an address info lookup hint based on the family and type properties of a socket descriptor. | |
| static char * | gethostname (struct sockaddr *address, char *buffer, size_t size) |
| Lookup and return the host name associated with a socket address. | |
| static int | getinterface (struct sockaddr *address, struct sockaddr *destination) |
| Get the socket address of the interface needed to reach a destination address. | |
| static socklen_t | getlen (struct sockaddr *address) |
| Get the size of a socket address. | |
| static int | getlocal (socket_t socket, struct sockaddr_storage *address) |
| Get local address to which the socket is bound. | |
| static set_t | getmask (void) |
| Get a mask from the heap. | |
| static int | getremote (socket_t socket, struct sockaddr_storage *address) |
| Get remote address to which the socket is connected. | |
| static short | getservice (struct sockaddr *address) |
| Get the service port of a socket. | |
| static int | gettype (socket_t socket) |
| Get the type of a socket. | |
| static short | inetservice (struct sockaddr_internet *address) |
| Get the service port of an inet socket. | |
| static void | init (const char *program) |
| Initialize with program name. | |
| static void | init (void) |
| Initialize socket subsystem. | |
| static bool | isNull (const char *string) |
| Simple function to validate that a given IP address string is a "zero" address. | |
| static bool | isNumeric (const char *string) |
| Simple function to validate that a given IP address string is a numeric address. | |
| static int | join (socket_t socket, struct addrinfo *list) |
| Join socket descriptor to multicast group. | |
| static int | keepalive (socket_t socket, bool enable) |
| Set socket for keepalive packets for socket descriptor. | |
| static unsigned | keyhost (struct sockaddr *address, unsigned size) |
| Convert a socket host address into a hash map index. | |
| static unsigned | keyindex (struct sockaddr *address, unsigned size) |
| Convert a socket address and service into a hash map index. | |
| static int | listento (socket_t socket, struct sockaddr *address, int backlog=5) |
| Bind the socket descriptor to a known interface listen on service port. | |
| static int | loopback (socket_t socket, bool enable) |
| Set loopback to read multicast packets socket descriptor broadcasts. | |
| static int | multicast (socket_t socket, unsigned ttl=1) |
| Set multicast mode and multicast broadcast range for socket descriptor. | |
| static int | nodelay (socket_t socket) |
| Set tcp nodelay option on socket descriptor. | |
| static FILE * | open (socket_t socket, bool mode=false) |
| Convert socket into FILE handle for reading. | |
| static unsigned | pending (socket_t socket) |
| Get the number of bytes pending in the receive buffer of a socket descriptor. | |
| static ssize_t | printf (socket_t socket, const char *format,...) |
| Print formatted string to socket. | |
| static int | priority (socket_t socket, int scheduling) |
| Set packet priority of socket descriptor. | |
| static ssize_t | readfrom (Socket &socket, char *buffer, size_t size, struct sockaddr_storage *address) |
| receive from socket object. | |
| static ssize_t | readline (socket_t socket, char *data, size_t size, timeout_t timeout=Timer::inf) |
| Read a newline of text data from the socket and save in NULL terminated string. | |
| static ssize_t | recvfrom (socket_t socket, void *buffer, size_t size, int flags=0, struct sockaddr_storage *address=NULL) |
| Get data waiting in receive queue. | |
| static ssize_t | recvinet (socket_t socket, void *buffer, size_t size, int flags=0, struct sockaddr_internet *address=NULL) |
| Get internet data waiting in receive queue. | |
| static int | recvsize (socket_t socket, unsigned size) |
| Set the receive size of a socket descriptor. | |
| static void | release (set_t mask) |
| Release a heap allocated mask. | |
| static void | release (socket_t socket) |
| Release (close) a socket. | |
| static ssize_t | replyto (socket_t socket, const void *buffer, size_t size, int flags, struct sockaddr_storage *address) |
| Send reply on socket. | |
| static unsigned | segsize (socket_t socket, unsigned size=0) |
| Set segment size and get MTU. | |
| static int | select (int max, set_t read, set_t write, set_t error, timeout_t timeout) |
| Select with timeout. | |
| static int | select (int max, set_t read, set_t write, set_t error) |
| Select without timeout. | |
| static ssize_t | sendinet (socket_t socket, const void *buffer, size_t size, int flags, struct sockaddr_internet *address) |
| Send to internet socket. | |
| static int | sendsize (socket_t socket, unsigned size) |
| Set the send size of a socket descriptor. | |
| static ssize_t | sendto (socket_t socket, const void *buffer, size_t size, int flags=0, struct sockaddr *address=NULL) |
| Send data on socket. | |
| static int | sendwait (socket_t socket, unsigned size) |
| Set the size to wait before sending. | |
| static void | set (socket_t socket, set_t mask) |
| Set a socket entry in a mask. | |
| static bool | setccid (socket_t socket, uint8_t ccid) |
| Set congestion control id. | |
| static unsigned | store (struct sockaddr_internet *storage, struct sockaddr *address) |
| Store an address into an internet address object. | |
| static unsigned | store (struct sockaddr_storage *storage, struct sockaddr *address) |
| Store an address into an address object. | |
| static bool | subnet (struct sockaddr *address1, struct sockaddr *address2) |
| See if both addresses are in the same subnet. | |
| static bool | test (socket_t socket, set_t mask) |
| Test a socket entry in a mask. | |
| static int | tos (socket_t socket, int type) |
| Set type of service of socket descriptor. | |
| static int | ttl (socket_t socket, unsigned char time) |
| Set the time to live for the socket descriptor. | |
| static void | v4mapping (bool enable) |
| Set the default socket behavior for v6-v4 mapping. | |
| static bool | wait (socket_t socket, timeout_t timeout=0) |
| Test for pending input data. | |
| static ssize_t | writeto (Socket &socket, const char *buffer, size_t size, struct sockaddr *address) |
| Send to socket object. | |
Static Public Attributes | |
| static const size_t | masksize |
Static Protected Member Functions | |
| static struct addrinfo * | getaddress (const char *host, const char *service, int type=SOCK_STREAM, int protocol=0) |
| Get an address list directly. | |
| static void | release (struct addrinfo *list) |
| Release an address list directly. | |
Protected Attributes | |
| socket_t | so |
Friends | |
| class | address |
A generic socket base class.
This class can be used directly or as a base class for building network protocol stacks. This common base tries to handle UDP and TCP sockets, as well as support multicast, IPV4/IPV6 addressing, and additional addressing domains (such as Unix domain sockets).
Definition at line 295 of file socket.h.
| typedef void* ucc::Socket::set_t |
| ucc::Socket::Socket | ( | const Socket & | existing | ) |
Create socket as duped handle of existing socket.
| existing | socket to dup. |
| ucc::Socket::Socket | ( | socket_t | socket | ) |
Create socket from existing socket descriptor.
| socket | descriptor to use. |
| ucc::Socket::Socket | ( | struct addrinfo * | address | ) |
Create and connect a socket to an address from an address list.
The type of socket created is based on the type we are connecting to.
| address | list to connect with. |
| ucc::Socket::Socket | ( | int | family, | |
| int | type, | |||
| int | protocol = 0 | |||
| ) |
Create an unbound socket of a specific type.
| family | of our new socket. | |
| type | (stream, udp, etc) of our new socket. | |
| protocol | number of our new socket.' |
| ucc::Socket::Socket | ( | const char * | address, | |
| const char * | port, | |||
| int | family = AF_UNSPEC, |
|||
| int | type = 0, |
|||
| int | protocol = 0, |
|||
| int | backlog = 0 | |||
| ) |
Create a bound socket.
| address | to bind or "*" for all | |
| port | number of service to bind. | |
| family | to bind as. | |
| type | of socket to bind (stream, udp, etc). | |
| protocol | of socket to bind. | |
| backlog | for listening socket. |
| static socket_t ucc::Socket::acceptfrom | ( | socket_t | socket, | |
| struct sockaddr_storage * | address = NULL | |||
| ) | [static] |
Accept a socket connection from a remote host.
| socket | descriptor to accept from. | |
| address | of socket accepting. |
| static int ucc::Socket::bindto | ( | socket_t | socket, | |
| struct sockaddr * | address | |||
| ) | [static] |
Bind the socket descriptor to a known interface.
| socket | descriptor to bind. | |
| address | of interface to bind to. |
| static int ucc::Socket::bindto | ( | socket_t | socket, | |
| const char * | address, | |||
| const char * | service, | |||
| int | protocol = 0 | |||
| ) | [static] |
Bind the socket descriptor to a known interface and service port.
| socket | descriptor to bind. | |
| address | to bind to or "*" for all. | |
| service | port to bind. | |
| protocol | to use or 0 if default. |
| static int ucc::Socket::blocking | ( | socket_t | socket, | |
| bool | enable | |||
| ) | [static] |
Set socket blocking I/O mode of socket descriptor.
| socket | descriptor. | |
| enable | true for blocking I/O. |
| int ucc::Socket::blocking | ( | bool | enable | ) | [inline] |
| static int ucc::Socket::broadcast | ( | socket_t | socket, | |
| bool | enable | |||
| ) | [static] |
Set socket for unicast mode broadcasts on socket descriptor.
| socket | descriptor. | |
| enable | broadcasting if true. |
| int ucc::Socket::broadcast | ( | bool | enable | ) | [inline] |
| static void ucc::Socket::cancel | ( | socket_t | socket | ) | [static] |
Cancel pending i/o by shutting down the socket.
| socket | to shutdown. |
| static void ucc::Socket::clear | ( | socket_t | socket, | |
| set_t | mask | |||
| ) | [static] |
Clear a socket entry in a mask.
| socket | entry to clear. | |
| mask | to set entry in. |
| static void ucc::Socket::clear | ( | set_t | mask | ) | [static] |
Clear a mask, setting all entries to zero.
| mask | to clear. |
| static void ucc::Socket::close | ( | FILE * | file | ) | [static] |
Cleanly close a connected socket descriptor mapped to a file handle.
| file | handle to close. |
| static void ucc::Socket::connectto | ( | Socket & | socket, | |
| Socket::address & | address | |||
| ) | [inline, static] |
| static int ucc::Socket::connectto | ( | socket_t | socket, | |
| struct addrinfo * | list | |||
| ) | [static] |
Connect socket descriptor to a remote host from an address list.
For TCP (and DCCP) sockets, the entire list may be tried. For UDP, connect is only a state and the first valid entry in the list is used.
| socket | descriptor. | |
| list | of addresses to connect to. |
| int ucc::Socket::connectto | ( | struct addrinfo * | list | ) | [inline] |
Connect our socket to a remote host from an address list.
For TCP (and DCCP) sockets, the entire list may be tried. For UDP, connect is only a state and the first valid entry in the list is used.
| list | of addresses to connect to. |
Definition at line 848 of file socket.h.

| static unsigned ucc::Socket::copy | ( | struct sockaddr * | target, | |
| struct sockaddr * | origin | |||
| ) | [static] |
Copy a socket address.
| target | address pointer to copy into. | |
| origin | address pointer to copy from. |
| static socket_t ucc::Socket::create | ( | Socket::address & | address | ) | [static] |
Create a connected socket for a service.
| address | of service for connect. |
| static socket_t ucc::Socket::create | ( | const char * | iface, | |
| const char * | service, | |||
| int | family = AF_UNSPEC, |
|||
| int | type = 0, |
|||
| int | protocol = 0, |
|||
| int | backlog = 0 | |||
| ) | [static] |
Create a bound socket for a service.
| iface | to bind. | |
| service | port to bind. | |
| family | to select or AF_UNSPEC | |
| type | of socket to create. | |
| protocol | of socket to create. | |
| backlog | for listener. |
| static socket_t ucc::Socket::create | ( | struct addrinfo * | address, | |
| int | type, | |||
| int | protocol | |||
| ) | [static] |
Create a connected socket.
| address | list to connect to. | |
| type | of socket to create. | |
| protocol | of socket. |
| static socket_t ucc::Socket::create | ( | int | family, | |
| int | type, | |||
| int | protocol | |||
| ) | [static] |
Create a socket object unbound.
| family | of socket. | |
| type | of socket. | |
| protocol | of socket. |
| static void ucc::Socket::disconnect | ( | Socket & | socket | ) | [inline, static] |
| static int ucc::Socket::disconnect | ( | socket_t | socket | ) | [static] |
Disconnect a connected socket descriptor.
| socket | descriptor. |
| int ucc::Socket::disconnect | ( | void | ) | [inline] |
| static int ucc::Socket::drop | ( | socket_t | socket, | |
| struct addrinfo * | list | |||
| ) | [static] |
Drop socket descriptor from multicast group.
| socket | descriptor. | |
| list | of groups to drop. |
| int ucc::Socket::drop | ( | struct addrinfo * | list | ) | [inline] |
| static bool ucc::Socket::equal | ( | struct sockaddr * | address1, | |
| struct sockaddr * | address2 | |||
| ) | [static] |
Compare socket addresses.
Test if the address and service matches or if there is no service, then just the host address values.
| address1 | to compare. | |
| address2 | to compare. |
| static bool ucc::Socket::equalfrom | ( | struct sockaddr_storage * | address1, | |
| struct sockaddr_storage * | address2 | |||
| ) | [inline, static] |
| static bool ucc::Socket::equalhost | ( | struct sockaddr * | address1, | |
| struct sockaddr * | address2 | |||
| ) | [static] |
Compare socket host addresses.
Test if the host addressmatches or if there is no service, then just the host address values.
| address1 | to compare. | |
| address2 | to compare. |
| static bool ucc::Socket::equalinet | ( | struct sockaddr_internet * | address1, | |
| struct sockaddr_internet * | address2 | |||
| ) | [inline, static] |
| static int ucc::Socket::error | ( | void | ) | [static] |
Return error code of last socket operation,.
| static int ucc::Socket::error | ( | socket_t | socket | ) | [static] |
Get socket error code of socket descriptor.
| socket | descriptor. |
| static void ucc::Socket::family | ( | int | query | ) | [static] |
Set default socket family preference for query options when the socket type is otherwise not specified.
| query | family to select. |
| virtual ssize_t ucc::Socket::get | ( | void * | data, | |
| size_t | number, | |||
| struct sockaddr_storage * | address = NULL | |||
| ) | [virtual] |
Read data from the socket receive buffer.
This is a virtual so that the ssl layer can override the core get method.
| data | pointer to save data in. | |
| number | of bytes to read. | |
| address | of peer data was received from. |
| static socklen_t ucc::Socket::getaddr | ( | socket_t | socket, | |
| struct sockaddr_storage * | address, | |||
| const char * | hostname, | |||
| const char * | service | |||
| ) | [static] |
Lookup a host name and service address based on the addressing family and socket type of a socket descriptor.
Store the result in a socket address structure.
| socket | descriptor. | |
| address | that is resolved. | |
| hostname | to resolve. | |
| service | port. |
| static char* ucc::Socket::getaddress | ( | struct sockaddr * | address, | |
| char * | buffer, | |||
| socklen_t | size | |||
| ) | [static] |
Get the hostname of a socket address.
| address | to lookup. | |
| buffer | to save hostname in. | |
| size | of hostname buffer. |
| static struct addrinfo* ucc::Socket::getaddress | ( | const char * | host, | |
| const char * | service, | |||
| int | type = SOCK_STREAM, |
|||
| int | protocol = 0 | |||
| ) | [static, read, protected] |
Get an address list directly.
This is used internally by some derived socket types when generic address lists would be invalid.
| host | name in the form address or "address:port" | |
| service | id or port to use if not specified in host string. | |
| type | of service to get. | |
| protocol | of service to get. |
| int ucc::Socket::getError | ( | void | ) | [inline] |
| static int ucc::Socket::getfamily | ( | struct sockaddr_internet & | address | ) | [inline, static] |
| static int ucc::Socket::getfamily | ( | struct sockaddr_storage & | address | ) | [inline, static] |
| static int ucc::Socket::getfamily | ( | socket_t | socket | ) | [static] |
Get the address family of the socket descriptor.
| static struct addrinfo* ucc::Socket::gethint | ( | socket_t | socket, | |
| struct addrinfo * | hint | |||
| ) | [static, read] |
Create an address info lookup hint based on the family and type properties of a socket descriptor.
| socket | descriptor. | |
| hint | buffer. |
| static char* ucc::Socket::gethostname | ( | struct sockaddr * | address, | |
| char * | buffer, | |||
| size_t | size | |||
| ) | [static] |
Lookup and return the host name associated with a socket address.
| address | to lookup. | |
| buffer | to save hostname into. | |
| size | of buffer to save hostname into. |
| static int ucc::Socket::getinterface | ( | struct sockaddr * | address, | |
| struct sockaddr * | destination | |||
| ) | [static] |
Get the socket address of the interface needed to reach a destination address.
| address | of interface found. | |
| destination | address. |
| static socklen_t ucc::Socket::getlen | ( | struct sockaddr * | address | ) | [static] |
Get the size of a socket address.
| address | of socket. |
| static int ucc::Socket::getlocal | ( | socket_t | socket, | |
| struct sockaddr_storage * | address | |||
| ) | [static] |
Get local address to which the socket is bound.
This is defined here because we may re-define the backend linkage for the socks proxy in the future.
| socket | descriptor to examine. | |
| address | storage for local address. |
| static set_t ucc::Socket::getmask | ( | void | ) | [static] |
Get a mask from the heap.
| unsigned ucc::Socket::getPending | ( | void | ) | const [inline] |
| static int ucc::Socket::getremote | ( | socket_t | socket, | |
| struct sockaddr_storage * | address | |||
| ) | [static] |
Get remote address to which the socket is connected.
This is defined here because we may re-define the backend linkage for the socks proxy in the future.
| socket | descriptor to examine. | |
| address | storage for remote address. |
| virtual ssize_t ucc::Socket::gets | ( | char * | data, | |
| size_t | size, | |||
| timeout_t | timeout = Timer::inf | |||
| ) | [virtual] |
Read a newline of text data from the socket and save in NULL terminated string.
This uses an optimized I/O method that takes advantage of socket peeking. As such, it has to be rewritten to be used in a ssl layer socket.
| data | to save input line. | |
| size | of input line buffer. | |
| timeout | to wait for a complete input line. |
| static short ucc::Socket::getservice | ( | struct sockaddr * | address | ) | [static] |
Get the service port of a socket.
| address | of socket to examine. |
| int ucc::Socket::gettype | ( | void | ) | [inline] |
| static int ucc::Socket::gettype | ( | socket_t | socket | ) | [static] |
Get the type of a socket.
| socket | descriptor. |
| static short ucc::Socket::inetservice | ( | struct sockaddr_internet * | address | ) | [inline, static] |
| static void ucc::Socket::init | ( | const char * | program | ) | [static] |
Initialize with program name.
Used by socks, for example.
| program | name. |
| bool ucc::Socket::isConnected | ( | void | ) | const |
Test if socket is connected.
| static bool ucc::Socket::isNull | ( | const char * | string | ) | [static] |
Simple function to validate that a given IP address string is a "zero" address.
Such address strings are used for example in SIP to indicate "hold" by re-inviting peers to a null address. Supports IPV4 and IPV6 addresses.
| string | address to check. |
| static bool ucc::Socket::isNumeric | ( | const char * | string | ) | [static] |
Simple function to validate that a given IP address string is a numeric address.
This can be used to verify an address is not a "host" name. Supports IPV4 and IPV6 address strings.
| string | address to check. |
| bool ucc::Socket::isPending | ( | unsigned | value | ) | const |
See the number of bytes in the receive queue.
| value | to test for. |
| static int ucc::Socket::join | ( | socket_t | socket, | |
| struct addrinfo * | list | |||
| ) | [static] |
Join socket descriptor to multicast group.
| socket | descriptor. | |
| list | of groups to join. |
| int ucc::Socket::join | ( | struct addrinfo * | list | ) | [inline] |
| static int ucc::Socket::keepalive | ( | socket_t | socket, | |
| bool | enable | |||
| ) | [static] |
Set socket for keepalive packets for socket descriptor.
| socket | descriptor. | |
| enable | keep-alive if true. |
| int ucc::Socket::keepalive | ( | bool | enable | ) | [inline] |
| static unsigned ucc::Socket::keyhost | ( | struct sockaddr * | address, | |
| unsigned | size | |||
| ) | [static] |
Convert a socket host address into a hash map index.
| address | to convert. | |
| size | of map index. |
| static unsigned ucc::Socket::keyindex | ( | struct sockaddr * | address, | |
| unsigned | size | |||
| ) | [static] |
Convert a socket address and service into a hash map index.
| address | to convert. | |
| size | of map index. |
| static int ucc::Socket::listento | ( | socket_t | socket, | |
| struct sockaddr * | address, | |||
| int | backlog = 5 | |||
| ) | [static] |
Bind the socket descriptor to a known interface listen on service port.
| socket | descriptor to bind. | |
| address | of interface to bind to. | |
| backlog | for service. |
| static int ucc::Socket::loopback | ( | socket_t | socket, | |
| bool | enable | |||
| ) | [static] |
Set loopback to read multicast packets socket descriptor broadcasts.
| socket | descriptor. | |
| enable | true to loopback, false to ignore. |
| int ucc::Socket::loopback | ( | bool | enable | ) | [inline] |
| static int ucc::Socket::multicast | ( | socket_t | socket, | |
| unsigned | ttl = 1 | |||
| ) | [static] |
Set multicast mode and multicast broadcast range for socket descriptor.
| socket | descriptor. | |
| ttl | to set for multicast socket or 0 to disable multicast. |
| int ucc::Socket::multicast | ( | unsigned | ttl = 1 |
) | [inline] |
| static int ucc::Socket::nodelay | ( | socket_t | socket | ) | [static] |
Set tcp nodelay option on socket descriptor.
| socket | desciptor. |
| int ucc::Socket::nodelay | ( | void | ) | const [inline] |
| FILE* ucc::Socket::open | ( | bool | mode = false |
) | [inline] |
| static FILE* ucc::Socket::open | ( | socket_t | socket, | |
| bool | mode = false | |||
| ) | [static] |
Convert socket into FILE handle for reading.
| socket | descriptor to convert. | |
| mode | of access, true for write mode. |
| ucc::Socket::operator bool | ( | ) |
Test if socket is valid.
| ucc::Socket::operator socket_t | ( | ) | const [inline] |
Get the socket descriptor by casting.
Reimplemented in ucc::ListenSocket.
| bool ucc::Socket::operator! | ( | ) | const |
Test if socket is invalid.
| socket_t ucc::Socket::operator* | ( | ) | const [inline] |
Get the socket descriptor by pointer reference.
Reimplemented in ucc::ListenSocket.
| Socket& ucc::Socket::operator= | ( | socket_t | socket | ) |
Assign socket from a socket descriptor.
Release existing socket if one present.
| socket | descriptor to assign to object. |
| size_t ucc::Socket::peek | ( | void * | data, | |
| size_t | number | |||
| ) | const |
Peek at data waiting in the socket receive buffer.
| data | pointer to save data in. | |
| number | of bytes to peek. |
| static unsigned ucc::Socket::pending | ( | socket_t | socket | ) | [static] |
Get the number of bytes pending in the receive buffer of a socket descriptor.
| socket | descriptor. |
| static ssize_t ucc::Socket::printf | ( | socket_t | socket, | |
| const char * | format, | |||
| ... | ||||
| ) | [static] |
Print formatted string to socket.
| socket | to write to. | |
| format | string. |
| static int ucc::Socket::priority | ( | socket_t | socket, | |
| int | scheduling | |||
| ) | [static] |
Set packet priority of socket descriptor.
| socket | descriptor. | |
| scheduling | priority for packet scheduling. |
| int ucc::Socket::priority | ( | int | scheduling | ) | [inline] |
| virtual ssize_t ucc::Socket::put | ( | const void * | data, | |
| size_t | number, | |||
| struct sockaddr * | address = NULL | |||
| ) | [virtual] |
Write data to the socket send buffer.
This is a virtual so that the ssl layer can override the core put method.
| data | pointer to write data from. | |
| number | of bytes to write. | |
| address | of peer to send data to if not connected. |
| ssize_t ucc::Socket::puts | ( | const char * | string, | |
| struct sockaddr * | address | |||
| ) |
| ssize_t ucc::Socket::puts | ( | const char * | string | ) |
Write a null terminated string to the socket.
| string | to write. |
| static ssize_t ucc::Socket::readfrom | ( | Socket & | socket, | |
| char * | buffer, | |||
| size_t | size, | |||
| struct sockaddr_storage * | address | |||
| ) | [inline, static] |
| ssize_t ucc::Socket::readfrom | ( | void * | data, | |
| size_t | number, | |||
| struct sockaddr_storage * | address = NULL | |||
| ) | [inline] |
| static ssize_t ucc::Socket::readline | ( | socket_t | socket, | |
| char * | data, | |||
| size_t | size, | |||
| timeout_t | timeout = Timer::inf | |||
| ) | [static] |
Read a newline of text data from the socket and save in NULL terminated string.
This uses an optimized I/O method that takes advantage of socket peeking. As such, it has to be rewritten to be used in a ssl layer socket.
| socket | to read from. | |
| data | to save input line. | |
| size | of input line buffer. | |
| timeout | to wait for a complete input line. |
| static ssize_t ucc::Socket::recvfrom | ( | socket_t | socket, | |
| void * | buffer, | |||
| size_t | size, | |||
| int | flags = 0, |
|||
| struct sockaddr_storage * | address = NULL | |||
| ) | [static] |
Get data waiting in receive queue.
| socket | to get from. | |
| buffer | to save. | |
| size | of data buffer to request. | |
| flags | for i/o operation (MSG_OOB, MSG_PEEK, etc). | |
| address | of source. |
| static ssize_t ucc::Socket::recvinet | ( | socket_t | socket, | |
| void * | buffer, | |||
| size_t | size, | |||
| int | flags = 0, |
|||
| struct sockaddr_internet * | address = NULL | |||
| ) | [static] |
Get internet data waiting in receive queue.
| socket | to get from. | |
| buffer | to save. | |
| size | of data buffer to request. | |
| flags | for i/o operation (MSG_OOB, MSG_PEEK, etc). | |
| address | of source. |
| static int ucc::Socket::recvsize | ( | socket_t | socket, | |
| unsigned | size | |||
| ) | [static] |
Set the receive size of a socket descriptor.
| socket | descriptor. | |
| size | of receive buffer to set. |
| int ucc::Socket::recvsize | ( | unsigned | size | ) | [inline] |
| static void ucc::Socket::release | ( | set_t | mask | ) | [static] |
Release a heap allocated mask.
| mask | to release. |
| static void ucc::Socket::release | ( | socket_t | socket | ) | [static] |
Release (close) a socket.
| socket | to close. |
| static void ucc::Socket::release | ( | struct addrinfo * | list | ) | [static, protected] |
Release an address list directly.
This is used internally by some derived socket types which do not use generic address lists.
| list | of addresses. |
| static ssize_t ucc::Socket::replyto | ( | socket_t | socket, | |
| const void * | buffer, | |||
| size_t | size, | |||
| int | flags, | |||
| struct sockaddr_storage * | address | |||
| ) | [inline, static] |
| unsigned ucc::Socket::segsize | ( | unsigned | size | ) | [inline] |
| static unsigned ucc::Socket::segsize | ( | socket_t | socket, | |
| unsigned | size = 0 | |||
| ) | [static] |
Set segment size and get MTU.
| socket | to modify. | |
| size | of segment or zero to not set. |
| static int ucc::Socket::select | ( | int | max, | |
| set_t | read, | |||
| set_t | write, | |||
| set_t | error, | |||
| timeout_t | timeout | |||
| ) | [static] |
Select with timeout.
| max | socket id + 1. | |
| read | mask of socket id's. | |
| write | mask of socket id's. | |
| error | mask of socket id's. | |
| timeout | in milliseconds to wait for select activity. |
Select without timeout.
| max | socket id + 1. | |
| read | mask of socket id's. | |
| write | mask of socket id's. | |
| error | mask of socket id's. |
| static ssize_t ucc::Socket::sendinet | ( | socket_t | socket, | |
| const void * | buffer, | |||
| size_t | size, | |||
| int | flags, | |||
| struct sockaddr_internet * | address | |||
| ) | [inline, static] |
| static int ucc::Socket::sendsize | ( | socket_t | socket, | |
| unsigned | size | |||
| ) | [static] |
Set the send size of a socket descriptor.
| socket | descriptor. | |
| size | of send buffer to set. |
| int ucc::Socket::sendsize | ( | unsigned | size | ) | [inline] |
| static ssize_t ucc::Socket::sendto | ( | socket_t | socket, | |
| const void * | buffer, | |||
| size_t | size, | |||
| int | flags = 0, |
|||
| struct sockaddr * | address = NULL | |||
| ) | [static] |
Send data on socket.
| socket | to send to. | |
| buffer | to send. | |
| size | of data buffer to send. | |
| flags | for i/o operation (MSG_OOB, MSG_PEEK, etc). | |
| address | of destination, NULL if connected. |
| static int ucc::Socket::sendwait | ( | socket_t | socket, | |
| unsigned | size | |||
| ) | [static] |
Set the size to wait before sending.
| socket | descriptor. | |
| size | of send wait buffer to set. |
| int ucc::Socket::sendwait | ( | unsigned | size | ) | [inline] |
| static void ucc::Socket::set | ( | socket_t | socket, | |
| set_t | mask | |||
| ) | [static] |
Set a socket entry in a mask.
| socket | entry to set. | |
| mask | to set entry in. |
| bool ucc::Socket::setccid | ( | uint8_t | ccid | ) | [inline] |
| static bool ucc::Socket::setccid | ( | socket_t | socket, | |
| uint8_t | ccid | |||
| ) | [static] |
Set congestion control id.
| socket | to modify. | |
| ccid | value to set. |
| static unsigned ucc::Socket::store | ( | struct sockaddr_internet * | storage, | |
| struct sockaddr * | address | |||
| ) | [static] |
Store an address into an internet address object.
| storage | for address. | |
| address | to store. |
| static unsigned ucc::Socket::store | ( | struct sockaddr_storage * | storage, | |
| struct sockaddr * | address | |||
| ) | [inline, static] |
| static bool ucc::Socket::subnet | ( | struct sockaddr * | address1, | |
| struct sockaddr * | address2 | |||
| ) | [static] |
See if both addresses are in the same subnet.
This is only relevent to IPV4 and class domain routing.
| address1 | to test. | |
| address2 | to test. |
| static bool ucc::Socket::test | ( | socket_t | socket, | |
| set_t | mask | |||
| ) | [static] |
Test a socket entry in a mask.
| socket | entry to test. | |
| mask | to set entry in. |
| static int ucc::Socket::tos | ( | socket_t | socket, | |
| int | type | |||
| ) | [static] |
Set type of service of socket descriptor.
| socket | descriptor. | |
| type | of service. |
| int ucc::Socket::tos | ( | int | type | ) | [inline] |
Set the type of service field of outgoing packets.
Some useful values include IPTOS_LOWDELAY to minimize delay for interactive traffic, IPTOS_THROUGHPUT to optimize thoughput, OPTOS_RELIABILITY to optimize for reliability, and IPTOS_MINCOST for low speed use.
| type | of service value. |
Definition at line 823 of file socket.h.

| static int ucc::Socket::ttl | ( | socket_t | socket, | |
| unsigned char | time | |||
| ) | [static] |
Set the time to live for the socket descriptor.
| socket | descriptor. | |
| time | to live to set. |
| int ucc::Socket::ttl | ( | unsigned char | time | ) | [inline] |
| static void ucc::Socket::v4mapping | ( | bool | enable | ) | [static] |
Set the default socket behavior for v6-v4 mapping.
This also effects v6 address lookup as to whether v4 remapped addresses can be used if no v6 address is found.
| enable | true to set mapping. This is default. |
| static bool ucc::Socket::wait | ( | socket_t | socket, | |
| timeout_t | timeout = 0 | |||
| ) | [static] |
Test for pending input data.
This function can wait up to a specified timeout for data to appear.
| socket | to test. | |
| timeout | or 0 if none. |
| bool ucc::Socket::waitPending | ( | timeout_t | timeout = 0 |
) | const |
Test for pending input data.
This function can wait up to a specified timeout for data to appear.
| timeout | or 0 if none. |
| bool ucc::Socket::waitSending | ( | timeout_t | timeout = 0 |
) | const |
Test for output data sent.
This function can wait up to a specified timeout for data to appear sent.
| timeout | or 0 if none. |
| static ssize_t ucc::Socket::writeto | ( | Socket & | socket, | |
| const char * | buffer, | |||
| size_t | size, | |||
| struct sockaddr * | address | |||
| ) | [inline, static] |
| ssize_t ucc::Socket::writeto | ( | const void * | data, | |
| size_t | number, | |||
| struct sockaddr * | address = NULL | |||
| ) | [inline] |
1.6.3