UCommon
|
A generic socket base class. More...
#include <socket.h>
Data Structures | |
class | address |
A generic socket address class. More... | |
Public Types | |
typedef cidr | cidr_t |
typedef struct hostaddr_internet | host_t |
Public Member Functions | |
int | blocking (bool enable) |
Set socket blocking I/O mode. More... | |
int | broadcast (bool enable) |
Set socket for unicast mode broadcasts. More... | |
void | cancel (void) |
Cancel pending i/o by shutting down the socket. | |
bool | ccid (uint8_t id) |
Set ccid of dccp socket. More... | |
bool | connected (void) const |
Test if socket is connected. More... | |
int | connectto (struct addrinfo *list) |
Connect our socket to a remote host from an address list. More... | |
int | disconnect (void) |
Disconnect a connected socket. More... | |
int | drop (const struct addrinfo *list, const int ifindex=0) |
Drop socket from multicast group. More... | |
int | err (void) const |
Get error code. | |
int | getError (void) const |
Get socket error code. More... | |
bool | is_pending (unsigned value) |
See the number of bytes in the receive queue. More... | |
int | join (const struct addrinfo *list, const int ifindex=0) |
Join socket to multicast group. More... | |
int | keepalive (bool enable) |
Set socket for keepalive packets. More... | |
int | loopback (bool enable) |
Set loopback to read multicast packets we broadcast. More... | |
int | multicast (unsigned ttl=1) |
Set multicast mode and multicast broadcast range. More... | |
int | nodelay (void) const |
Set nodelay option for tcp socket. More... | |
socket_t | operator * () const |
Get the socket descriptor by pointer reference. More... | |
operator bool () const | |
Test if socket is valid. More... | |
operator socket_t () const | |
Get the socket descriptor by casting. More... | |
bool | operator! () const |
Test if socket is invalid. More... | |
Socket & | operator= (socket_t socket) |
Assign socket from a socket descriptor. More... | |
size_t | peek (void *data, size_t number) const |
Peek at data waiting in the socket receive buffer. More... | |
unsigned | pending (void) const |
Get the number of bytes of data in the socket receive buffer. More... | |
size_t | printf (const char *format,...) |
Print formatted string to socket. More... | |
int | priority (int scheduling) |
Set packet priority, 0 to 6 unless privileged. More... | |
size_t | readfrom (void *data, size_t number, struct sockaddr_storage *address=NULL) |
Read data from the socket receive buffer. More... | |
size_t | readline (char *data, size_t size) |
Read a newline of text data from the socket and save in NULL terminated string. More... | |
size_t | readline (String &buffer) |
Read a string of input from the socket and strip trailing newline. More... | |
stringref_t | readline (size_t maxsize) |
int | recvsize (unsigned size) |
Set the size of the socket receive buffer. More... | |
void | release (void) |
Shutdown and close the socket. | |
unsigned | segsize (unsigned size) |
Set segment size and get mtu of a socket. More... | |
int | sendsize (unsigned size) |
Set the size of the socket send buffer. More... | |
int | sendwait (unsigned size) |
Set the size to wait before sending. More... | |
void | shutdown (void) |
Shutdown the socket communication channel. | |
Socket () | |
Create a socket object for use. | |
Socket (const Socket &existing) | |
Create socket as duped handle of existing socket. More... | |
Socket (socket_t socket) | |
Create socket from existing socket descriptor. More... | |
Socket (const struct addrinfo *address) | |
Create and connect a socket to an address from an address list. More... | |
Socket (int family, int type, int protocol=0) | |
Create an unbound socket of a specific type. More... | |
Socket (const char *address, const char *port, int family=0, int type=0, int protocol=0) | |
Create a bound socket. More... | |
int | tos (int type) |
Set the type of service field of outgoing packets. More... | |
int | ttl (uint8_t time) |
Set the time to live before packets expire. More... | |
int | type (void) const |
Get the type of a socket. More... | |
bool | wait (timeout_t timeout=0) const |
Test for pending input data. More... | |
int | wait (timeout_t timeout=Timer::inf) |
Socket i/o timer setting. More... | |
bool | waitSending (timeout_t timeout=0) const |
Test for output data sent. More... | |
size_t | writes (const char *string) |
Write a null terminated string to the socket. More... | |
size_t | writeto (const void *data, size_t number, const struct sockaddr *address=NULL) |
Write data to the socket send buffer. More... | |
virtual | ~Socket () |
Shutdown, close, and destroy socket. | |
Static Public Member Functions | |
static socket_t | acceptfrom (socket_t socket, struct sockaddr_storage *address=NULL) |
Accept a socket connection from a remote host. More... | |
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. More... | |
static int | bindto (socket_t socket, const struct sockaddr *address) |
Bind the socket descriptor to a known interface. More... | |
static int | blocking (socket_t socket, bool enable) |
Set socket blocking I/O mode of socket descriptor. More... | |
static int | broadcast (socket_t socket, bool enable) |
Set socket for unicast mode broadcasts on socket descriptor. More... | |
static void | cancel (socket_t socket) |
Cancel pending i/o by shutting down the socket. More... | |
static bool | ccid (socket_t socket, uint8_t id) |
Set congestion control id. More... | |
static int | connectto (socket_t socket, struct addrinfo *list) |
Connect socket descriptor to a remote host from an address list. More... | |
static unsigned | copy (struct sockaddr *target, const struct sockaddr *origin) |
Copy a socket address. More... | |
static socket_t | create (int family, int type, int protocol) |
Create a socket object unbound. More... | |
static socket_t | create (const struct addrinfo *address, int type, int protocol) |
Create a connected socket. More... | |
static socket_t | create (const char *iface, const char *service, int family=0, int type=0, int protocol=0) |
Create a bound socket for a service. More... | |
static socket_t | create (const Socket::address &address) |
Create a connected socket for a service. More... | |
static int | disconnect (socket_t socket) |
Disconnect a connected socket descriptor. More... | |
static int | drop (socket_t socket, const struct addrinfo *list, const int ifindex=0) |
Drop socket descriptor from multicast group. More... | |
static bool | eq_from (const struct sockaddr_storage *address1, const struct sockaddr_storage *address2) |
Compare socket addresses. More... | |
static bool | eq_host (const struct sockaddr *address1, const struct sockaddr *address2) |
Compare socket host addresses. More... | |
static bool | eq_inet (const struct sockaddr_internet *address1, const struct sockaddr_internet *address2) |
Compare socket addresses. More... | |
static bool | eq_subnet (const struct sockaddr *address1, const struct sockaddr *address2) |
See if both addresses are in the same subnet. More... | |
static bool | equal (const struct sockaddr *address1, const struct sockaddr *address2) |
Compare socket addresses. More... | |
static int | error (const socket_t socket) |
Get socket error code of socket descriptor. More... | |
static int | error (void) |
Return error code of last socket operation,. More... | |
static int | family (socket_t socket) |
Get the address family of the socket descriptor. More... | |
static int | family (const struct sockaddr_storage &address) |
Get the address family of a socket address object. More... | |
static int | family (const struct sockaddr_internet &address) |
Get the address family of an internet socket address object. More... | |
static struct addrinfo * | hinting (socket_t socket, struct addrinfo *hint) |
Create an address info lookup hint based on the family and type properties of a socket descriptor. More... | |
static char * | hostname (const struct sockaddr *address, char *buffer, size_t size) |
Lookup and return the host name associated with a socket address. More... | |
static void | init (void) |
Initialize socket subsystem. | |
static bool | is_null (const char *string) |
Simple function to validate that a given IP address string is a "zero" address. More... | |
static bool | is_numeric (const char *string) |
Simple function to validate that a given IP address string is a numeric address. More... | |
static int | join (socket_t socket, const struct addrinfo *list, const int ifindex=0) |
Join socket descriptor to multicast group. More... | |
static int | keepalive (socket_t socket, bool enable) |
Set socket for keepalive packets for socket descriptor. More... | |
static unsigned | keyhost (const struct sockaddr *address, unsigned size) |
Convert a socket host address into a hash map index. More... | |
static unsigned | keyindex (const struct sockaddr *address, unsigned size) |
Convert a socket address and service into a hash map index. More... | |
static socklen_t | len (const struct sockaddr *address) |
Get the size of a socket address. More... | |
static int | listento (socket_t socket, const struct sockaddr *address, int backlog=5) |
Bind the socket descriptor to a known interface listen on service port. More... | |
static int | local (socket_t socket, struct sockaddr_storage *address) |
Get local address to which the socket is bound. More... | |
static int | loopback (socket_t socket, bool enable) |
Set loopback to read multicast packets socket descriptor broadcasts. More... | |
static int | multicast (socket_t socket, unsigned ttl=1) |
Set multicast mode and multicast broadcast range for socket descriptor. More... | |
static int | nodelay (socket_t socket) |
Set tcp nodelay option on socket descriptor. More... | |
static unsigned | pending (socket_t socket) |
Get the number of bytes pending in the receive buffer of a socket descriptor. More... | |
static in_port_t | port (const struct sockaddr *address) |
Get the service port of a socket. More... | |
static in_port_t | port (const struct sockaddr_internet *address) |
Get the service port of an inet socket. More... | |
static ssize_t | printf (socket_t socket, const char *format,...) |
Print formatted string to socket. More... | |
static int | priority (socket_t socket, int scheduling) |
Set packet priority of socket descriptor. More... | |
static struct addrinfo * | query (const char *host, const char *service, int type=SOCK_STREAM, int protocol=0) |
Get an address list directly. More... | |
static socklen_t | query (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. More... | |
static char * | query (const struct sockaddr *address, char *buffer, socklen_t size) |
Get the hostname of a socket address. More... | |
static void | query (int family) |
Set default socket family preference for query options when the socket type is otherwise not specified. More... | |
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. More... | |
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. More... | |
static int | recvsize (socket_t socket, unsigned size) |
Set the receive size of a socket descriptor. More... | |
static void | release (struct addrinfo *list) |
Release an address list directly. More... | |
static void | release (socket_t socket) |
Release (close) a socket. More... | |
static int | remote (socket_t socket, struct sockaddr_storage *address) |
Get remote address to which the socket is connected. More... | |
static ssize_t | replyto (socket_t socket, const void *buffer, size_t size, int flags, const struct sockaddr_storage *address) |
Send reply on socket. More... | |
static unsigned | segsize (socket_t socket, unsigned size=0) |
Set segment size and get MTU. More... | |
static int | sendsize (socket_t socket, unsigned size) |
Set the send size of a socket descriptor. More... | |
static ssize_t | sendto (socket_t socket, const void *buffer, size_t size, int flags=0, const struct sockaddr *address=NULL) |
Send data on socket. More... | |
static int | sendwait (socket_t socket, unsigned size) |
Set the size to wait before sending. More... | |
static unsigned | store (struct sockaddr_storage *storage, const struct sockaddr *address) |
Store an address into an address object. More... | |
static unsigned | store (struct sockaddr_internet *storage, const struct sockaddr *address) |
Store an address into an internet address object. More... | |
static int | tos (socket_t socket, int type) |
Set type of service of socket descriptor. More... | |
static int | ttl (socket_t socket, uint8_t time) |
Set the time to live for the socket descriptor. More... | |
static int | type (const socket_t socket) |
Get the type of a socket. More... | |
static void | v4mapping (bool enable) |
Set the default socket behavior for v6-v4 mapping. More... | |
static int | via (struct sockaddr *address, const struct sockaddr *target, socklen_t size=0) |
Get the socket address of the interface needed to reach a destination address. More... | |
static bool | wait (socket_t socket, timeout_t timeout=0) |
Test for pending input data. More... | |
Protected Attributes | |
int | ioerr |
timeout_t | iowait |
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).
ucommon::Socket::Socket | ( | const Socket & | existing | ) |
Create socket as duped handle of existing socket.
existing | socket to dup. |
ucommon::Socket::Socket | ( | socket_t | socket | ) |
Create socket from existing socket descriptor.
socket | descriptor to use. |
ucommon::Socket::Socket | ( | const 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. |
ucommon::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.' |
ucommon::Socket::Socket | ( | const char * | address, |
const char * | port, | ||
int | family = 0 , |
||
int | type = 0 , |
||
int | protocol = 0 |
||
) |
Create a bound socket.
If one wishes to listen for connections on a protocol, then ListenSocket should be used instead.
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. |
|
static |
Accept a socket connection from a remote host.
socket | descriptor to accept from. |
address | of socket accepting. |
|
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 |
Bind the socket descriptor to a known interface.
socket | descriptor to bind. |
address | of interface to bind to. |
|
inline |
|
static |
Set socket blocking I/O mode of socket descriptor.
socket | descriptor. |
enable | true for blocking I/O. |
|
inline |
|
static |
Set socket for unicast mode broadcasts on socket descriptor.
socket | descriptor. |
enable | broadcasting if true. |
|
static |
Cancel pending i/o by shutting down the socket.
socket | to shutdown. |
|
static |
Set congestion control id.
socket | to modify. |
ccid | value to set. |
|
inline |
bool ucommon::Socket::connected | ( | void | ) | const |
Test if socket is connected.
int ucommon::Socket::connectto | ( | struct addrinfo * | list | ) |
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. |
|
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. |
|
static |
Copy a socket address.
target | address pointer to copy into. |
origin | address pointer to copy from. |
|
static |
Create a socket object unbound.
family | of socket. |
type | of socket. |
protocol | of socket. |
|
static |
Create a connected socket.
address | list to connect to. |
type | of socket to create. |
protocol | of socket. |
|
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. |
|
static |
Create a connected socket for a service.
address | of service for connect. |
int ucommon::Socket::disconnect | ( | void | ) |
Disconnect a connected socket.
Depending on the implementation, this might be done by connecting to AF_UNSPEC, connecting to a 0 address, or connecting to self.
|
static |
Disconnect a connected socket descriptor.
socket | descriptor. |
int ucommon::Socket::drop | ( | const struct addrinfo * | list, |
const int | ifindex = 0 |
||
) |
Drop socket from multicast group.
list | of groups to drop. |
|
static |
Drop socket descriptor from multicast group.
socket | descriptor. |
list | of groups to drop. |
|
inlinestatic |
|
static |
Compare socket host addresses.
Test if the host address matches or if there is no service, then just the host address values.
address1 | to compare. |
address2 | to compare. |
|
inlinestatic |
|
static |
See if both addresses are in the same subnet.
This is only relevant to IPV4 and class domain routing.
address1 | to test. |
address2 | to test. |
|
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 |
Get socket error code of socket descriptor.
socket | descriptor. |
|
static |
Return error code of last socket operation,.
|
static |
Get the address family of the socket descriptor.
|
inlinestatic |
|
inlinestatic |
|
inline |
Create an address info lookup hint based on the family and type properties of a socket descriptor.
socket | descriptor. |
hint | buffer. |
|
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 |
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 |
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 ucommon::Socket::is_pending | ( | unsigned | value | ) |
See the number of bytes in the receive queue.
value | to test for. |
int ucommon::Socket::join | ( | const struct addrinfo * | list, |
const int | ifindex = 0 |
||
) |
Join socket to multicast group.
list | of groups to join. |
|
static |
Join socket descriptor to multicast group.
socket | descriptor. |
list | of groups to join. |
|
inline |
|
static |
Set socket for keepalive packets for socket descriptor.
socket | descriptor. |
enable | keep-alive if true. |
|
static |
Convert a socket host address into a hash map index.
address | to convert. |
size | of map index. |
|
static |
Convert a socket address and service into a hash map index.
address | to convert. |
size | of map index. |
|
static |
Get the size of a socket address.
address | of socket. |
|
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 |
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. |
|
inline |
|
static |
Set loopback to read multicast packets socket descriptor broadcasts.
socket | descriptor. |
enable | true to loopback, false to ignore. |
|
inline |
|
static |
Set multicast mode and multicast broadcast range for socket descriptor.
socket | descriptor. |
ttl | to set for multicast socket or 0 to disable multicast. |
|
inline |
|
static |
Set tcp nodelay option on socket descriptor.
socket | descriptor. |
|
inline |
ucommon::Socket::operator bool | ( | ) | const |
Test if socket is valid.
|
inline |
bool ucommon::Socket::operator! | ( | ) | const |
Test if socket is invalid.
Socket& ucommon::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 ucommon::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. |
|
inline |
|
static |
Get the number of bytes pending in the receive buffer of a socket descriptor.
socket | descriptor. |
|
static |
Get the service port of a socket.
address | of socket to examine. |
|
inlinestatic |
size_t ucommon::Socket::printf | ( | const char * | format, |
... | |||
) |
Print formatted string to socket.
format | string. |
|
static |
Print formatted string to socket.
socket | to write to. |
format | string. |
|
inline |
|
static |
Set packet priority of socket descriptor.
socket | descriptor. |
scheduling | priority for packet scheduling. |
|
static |
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. |
|
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 |
Get the hostname of a socket address.
address | to lookup. |
buffer | to save hostname in. |
size | of hostname buffer. |
|
static |
Set default socket family preference for query options when the socket type is otherwise not specified.
family | to select. |
size_t ucommon::Socket::readfrom | ( | void * | data, |
size_t | number, | ||
struct sockaddr_storage * | address = NULL |
||
) |
Read data from the socket receive buffer.
This will be used in abi 4.
data | pointer to save data in. |
number | of bytes to read. |
address | of peer data was received from. |
size_t ucommon::Socket::readline | ( | char * | data, |
size_t | size | ||
) |
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. This presumes a connected socket on a streamble protocol. Because the trailing newline is dropped, the return size may be greater than the string length. If there was no data read because of eof of data, an error has occured, or timeout without input, then 0 will be returned.
data | to save input line. |
size | of input line buffer. |
size_t ucommon::Socket::readline | ( | String & | buffer | ) |
Read a string of input from the socket and strip trailing newline.
This uses an optimized I/O method that takes advantage of socket peeking. This presumes a connected socket on a streamble protocol. Because the trailing newline is dropped, the return size may be greater than the string length. If there was no data read because of eof of data, an error has occured, or timeout without input, then 0 will be returned.
buffer | to save input line. |
|
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 |
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. |
|
inline |
|
static |
Set the receive size of a socket descriptor.
socket | descriptor. |
size | of receive buffer to set. |
|
static |
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 |
Release (close) a socket.
socket | to close. |
|
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. |
|
inlinestatic |
|
static |
Set segment size and get MTU.
socket | to modify. |
size | of segment or zero to not set. |
|
inline |
|
inline |
|
static |
Set the send size of a socket descriptor.
socket | descriptor. |
size | of send buffer to set. |
|
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. |
|
inline |
|
static |
Set the size to wait before sending.
socket | descriptor. |
size | of send wait buffer to set. |
|
static |
Store an address into an address object.
storage | for address. |
address | to store. |
|
static |
Store an address into an internet address object.
storage | for address. |
address | to store. |
|
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 throughput, OPTOS_RELIABILITY to optimize for reliability, and IPTOS_MINCOST for low speed use.
type | of service value. |
|
static |
Set type of service of socket descriptor.
socket | descriptor. |
type | of service. |
|
inline |
|
static |
Set the time to live for the socket descriptor.
socket | descriptor. |
time | to live to set. |
|
static |
Get the type of a socket.
socket | descriptor. |
|
inline |
|
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 |
Get the socket address of the interface needed to reach a destination address.
address | of interface found. |
target | address. |
size | of interface, 0 used for older code |
bool ucommon::Socket::wait | ( | 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. |
|
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. |
int ucommon::Socket::wait | ( | timeout_t | timeout = Timer::inf | ) |
Socket i/o timer setting.
timeout | to wait, inf for blocking, 0 pure non-blocking. |
bool ucommon::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. |
size_t ucommon::Socket::writes | ( | const char * | string | ) |
Write a null terminated string to the socket.
This exists because we messed up consistency with the original puts() method. In the future there will be a single puts() that has a NULL default.
string | to write. |
size_t ucommon::Socket::writeto | ( | const void * | data, |
size_t | number, | ||
const struct sockaddr * | address = NULL |
||
) |
Write data to the socket send buffer.
This will be used in abi 4.
data | pointer to write data from. |
number | of bytes to write. |
address | of peer to send data to if not connected. |