|
|
This class manages a socket. IPv6 support is automatically available, when supported by the system.
enum |
enum |
enum |
|
Constructor.
|
Constructor for a new socket. For automatic usage of IPv6 when available, set communication domain to IP. Use IPv4/IPv6 only if a special protocol version is necessary! The creation success can be checked using ready() method.
Parameters:
communicationDomain | Communication domain (e.g. IP). |
socketType | Socket type (e.g. TCP, UDP). |
socketProtocol | Socket protocol (e.g. Default). |
~ |
[virtual]
Destructor.
bool |
Close existing socket and create new socket. For automatic usage of IPv6 when available, set communication domain to IP. Use IPv4/IPv6 only if a special protocol version is necessary!
Parameters:
communicationDomain | Communication domain (e.g. IP). |
socketType | Socket type (e.g. TCP, UDP). |
socketProtocol | Socket protocol (e.g. Default). |
Returns: true, if creation was sucessful; false otherwise.
void |
Close socket.
void |
Shutdown full-duplex connection partial or completely. SHUT_RD - further receives will be disallowed. SHUT_WR - further sends will be disallowed. SHUT_RDWR - further sends and receives will be disallowed.
Parameters:
shutdownLevel | SHUT_RD, SHUT_WR, SHUT_RDWR. |
inline card64 |
[const]
Get number of bytes sent.
Returns: Number of bytes sent.
inline card64 |
[const]
Get number of bytes received.
Returns: Number of bytes received.
inline void |
Reset number of bytes sent.
inline void |
Reset number of bytes received.
inline bool |
[const]
Check, if socket is ready.
Returns: true, if socket is ready; false otherwise.
bool |
Bind socket to given address. If address is null address, then INADDR_ANY and an automatically selected port will be used.
Parameters:
address | Socket address. |
Returns: true on success; false otherwise.
bool |
Set socket to listen mode with given backlog (queue length for sockets waiting for acception).
Parameters:
backlog | Backlog. |
Returns: true on success; false otherwise.
Socket* |
Accept a connection.
Returns: New socket.
bool |
Connect socket to given address. A value for traffic class is supported if the connection is an IPv6 connection; otherwise it is ignored.
Parameters:
address | Address. |
trafficClass | Traffic class of the connection (IPv6 only!) |
Returns: true on success; false otherwise.
inline integer |
Get last error code. It will be reset to 0 after copying.
Returns: Last error code.
inline integer |
[const]
Get socket option (wrapper for getsockopt());
Parameters:
level | Level (e.g. SOL_SOCKET). |
optionNumber | Option (e.g. SO_REUSEADDR). |
optionValue | Memory to store option got from getsockopt(). |
optionLength | Memory with size of option memory. |
Returns: Result from getsockopt().
cardinal |
[const]
Get SO_LINGER option of socket.
Returns: SO_LINGER value.
bool |
[const]
Get SO_REUSEADDR option of socket.
Returns: SO_REUSEADDR value.
bool |
[const]
Get SO_BROADCAST option of socket.
Returns: SO_BROADCAST value.
bool |
[const]
Get TCP_NODELAY option of socket.
Returns: TCP_NODELAY value.
bool |
Check, if blocking mode is on.
Returns: true, if blocking mode is on; false otherwise.
inline integer |
Get socket option (wrapper for getsockopt());
Parameters:
level | Level (e.g. SOL_SOCKET). |
optionNumber | Option (e.g. SO_REUSEADDR). |
optionValue | Memory with option. |
optionLength | Length of option memory. |
Returns: Result from setsockopt().
void |
Set SO_LINGER option of socket.
Parameters:
on | true to set linger on; false otherwise. |
linger | SO_LINGER in seconds. |
void |
Set SO_REUSEADDR option of socket.
Parameters:
on | true to set SO_REUSEADDR on; false otherwise. |
void |
Set SO_BROADCAST option of socket.
Parameters:
on | true to set SO_BROADCAST on; false otherwise. |
void |
Set TCP_NODELAY option of socket.
Parameters:
on | true to set TCP_NODELAY on; false otherwise. |
void |
Set blocking mode.
Parameters:
on | True to set blocking mode, false to unset. |
inline card32 |
[const]
Get flow label of the connection.
Returns: Flow label of the connection or 0, if there is no flow label.
inline card8 |
[const]
Get traffic class of the connection.
Returns: Traffic class of the connection or 0, if there is no traffic class.
inline card32 |
[const]
Get last received flow label.
Returns: Last received flow label or 0, if there is no flow label.
inline card8 |
[const]
Get last received traffic class.
Returns: Last received traffic class or 0, if there is no traffic class.
ssize_t |
[virtual]
Wrapper for sendto(). sendto() will set the packet's traffic class, if trafficClass is not 0.
Parameters:
buffer | Buffer with data to send. |
length | Length of data to send. |
flags | Flags for sendto(). |
receiver | Address of receiver. |
Returns: Bytes sent or error code < 0.
ssize_t |
[virtual]
Wrapper for send(). send() will set the packet's traffic class, if trafficClass is not 0. In this case, the packet will be sent by sendto() to the destination address, the socket is connected to!
Parameters:
buffer | Buffer with data to send. |
length | Length of data to send. |
flags | Flags for sendto(). |
trafficClass | Traffic class for packet. |
Returns: Bytes sent or error code < 0.
ssize_t |
[virtual]
Wrapper for recvfrom().
Parameters:
buffer | Buffer to receive data to. |
length | Maximum length of data to be received. |
sender | Address to store sender's address. |
flags | Flags for recvfrom(). |
Returns: Bytes received or error code < 0.
ssize_t |
[virtual]
Wrapper for recv().
Parameters:
buffer | Buffer to read data to. |
length | Maximum length of data to be received. |
flags | Flags for recv(). |
Returns: Bytes read or error code < 0.
ssize_t |
[virtual]
Wrapper for read().
Parameters:
buffer | Buffer to read data to. |
length | Maximum length of data to be received. |
Returns: Bytes read or error code < 0.
ssize_t |
[virtual]
Wrapper for write().
Parameters:
buffer | Buffer with data to write |
length | Length of data to write |
Returns: Bytes sent or error code < 0.
inline integer |
Wrapper for fcntl().
Parameters:
cmd | Command. |
arg | Argument. |
Returns: Result of fcntl() call.
inline integer |
Wrapper for ioctl().
Parameters:
request | Request. |
argp | Argument. |
Returns: Result of ioctl() call.
bool |
[const]
Get the socket's address. Note: A socket has to be bound to an address and port or connected to a peer first to let the socket have an address!
Parameters:
address | Reference to SocketAddress to write address to. |
Returns: true, if call was successful; false otherwise.
See also: bind, connect, getPeerAddress
bool |
[const]
Get the peer's address. Note: A socket has to be connected to a peer first to get a peer address!
Parameters:
address | Reference to SocketAddress to write address to. |
Returns: true, if call was successful; false otherwise.
See also: bind, connect, getSocketAddress
InternetFlow |
Allocate a new flow to a given destination. A InternetFlow object is returned, the value flow.getFlowLabel() will not be 0, if the allocFlow() call was successful.
Parameters:
address | Address of the destination. |
flowLabel | Flowlabel; 0 for random value. |
shareLevel | Share level for flow label. |
Returns: InternetFlow.
void |
Free a flow.
Parameters:
flow | Flow to be freed. |
bool |
Renew a flow label allocation with given expires and linger (default 6) values. The expires value gives the seconds to go until the flow label expires, the linger value gives the timeout in seconds the freed flow label cannot be allocated again.
Parameters:
flow | Flow to be renewed. |
expires | Seconds until the flow label expires. |
linger | Linger (default 6). |
Returns: true on success; false otherwise.
bool |
Renew current flow's flow label allocation with given expires and linger (default 6) values.
Parameters:
expires | Seconds until the flow label expires. |
linger | Linger (default 6). |
Returns: true on success; false otherwise.
bool |
[static]
Bind a pair of internet sockets to a given address and port number x and x + 1. x will be a random number, if given port number is 0.
Parameters:
senderSocket | First socket. |
receiverSocket | Second socket. |
receiver | Address (e.g ipv6-localhost:0) or NULL for Any address. |
void |
[virtual]
Set traffic constraint to given byte rate. Packets exceeding the given constraint will be dropped. Note: This functionality has to be implemented by subclasses!
Parameters:
trafficClass | Traffic class. |
bandwidth | Bandwidth. |
bufferDelay | Maximum buffer delay in microseconds. |
void |
[virtual]
Flush traffic shaper buffer. Note: This functionality has to be implemented by subclasses!
inline int |
[const]
Get system's socket descriptor. Warning: It is not recommended to manipulate the socket directly. Use Socket's methods instead.
Returns: Socket descriptor.
static const cardinal |
Minimum port number for bind()'s automatic port selection.
static const cardinal |
Maximum port number for bind()'s automatic port selection.
friend class |
[protected]
void |
[protected]
bool |
[protected]
ssize_t |
[protected]
card64 |
[protected]
card64 |
[protected]
card32 |
[protected]
card32 |
[protected]
cardinal |
[protected]
cardinal |
[protected]
int |
[protected]
sockaddr* |
[protected]
SocketCommunicationDomain |
[protected]
SocketType |
[protected]
SocketProtocol |
[protected]