net
May 15, 2026 ยท View on GitHub
{#netmodule}
net
TCP/SSL/UDP networking, socket adapters, DNS resolution.
Namespaces
| Name | Description |
|---|---|
net | Socket transports, adapters, and address helpers. |
dns | DNS utilities. |
{#net}
net
Socket transports, adapters, and address helpers.
Classes
| Name | Description |
|---|---|
Address | Represents an IPv4 or IPv6 socket address with host and port. |
PacketSocketEmitter | Socket adapter that emits received data as packets. |
Socket | Base socket implementation from which all sockets derive. |
SocketAdapter | Abstract adapter interface for socket send/receive chains. |
SocketEmitter | SocketAdapter that exposes socket events as signals. |
SocketPacket | Default packet type emitted by sockets. |
SSLAdapter | Manages the OpenSSL context and BIO buffers for an SSL socket connection. |
SSLContext | OpenSSL SSL_CTX wrapper for client and server TLS configuration. |
SSLManager | Singleton that owns the default client/server TLS contexts and related callbacks. |
SSLSession | Cached SSL/TLS session wrapper used for client-side resumption. |
SSLSocket | SSL socket implementation. |
TCPSocket | TCP socket implementation. |
Transaction | Request/response helper for packet types emitted from a socket. |
UDPSocket | UDP socket implementation. |
VerificationErrorDetails | A utility class for certificate error handling. |
PacketInfo | Provides information about packets emitted from a socket. See SocketPacket. |
Enumerations
| Name | Description |
|---|---|
TransportType | Transport protocol identifier used to distinguish socket types at runtime. |
SocketMode | Transport mode for socket adapters and accepted connections. |
{#transporttype}
TransportType
enum TransportType
Transport protocol identifier used to distinguish socket types at runtime.
| Value | Description |
|---|---|
UDP | Unreliable datagram protocol. |
TCP | Reliable stream protocol. |
SSLTCP | TLS-encrypted TCP stream. |
{#socketmode}
SocketMode
enum SocketMode
Transport mode for socket adapters and accepted connections.
| Value | Description |
|---|---|
ServerSide | Server-side adapter. |
ClientSide | Client-side adapter. |
Functions
| Return | Name | Description |
|---|---|---|
std::shared_ptr< SocketT > | makeSocket inline | Creates a socket of type SocketT wrapped in a shared_ptr. |
SSLContext::VerificationMode | convertVerificationMode inline | Non-case sensitive conversion of a string to a VerificationMode enum. If verMode is illegal an ArgumentException is thrown. |
std::string | convertCertificateError inline | Converts an SSL certificate handling error code into an error message. |
std::string | getLastError inline | Returns the last error from the error stack. |
void | clearErrorStack inline | Clears the error stack. |
void | getNetworkInterfaces inline | Populates hosts with all local network interface addresses. |
int | getServerSocketSendBufSize | Returns the current send buffer size for a socket handle, in bytes. Passes val=0 to uv_send_buffer_size, which queries rather than sets the value. |
int | getServerSocketRecvBufSize | Returns the current receive buffer size for a socket handle, in bytes. Passes val=0 to uv_recv_buffer_size, which queries rather than sets the value. |
int | setServerSocketSendBufSize | Sets the send buffer size for a socket handle. |
int | setServerSocketRecvBufSize | Sets the receive buffer size for a socket handle. |
{#makesocket}
makeSocket
inline
template<class SocketT> inline std::shared_ptr< SocketT > makeSocket(uv::Loop * loop = uv::defaultLoop())
Creates a socket of type SocketT wrapped in a shared_ptr.
The socket is automatically destroyed when the last shared_ptr owner releases it.
Parameters
Parameters
loopEvent loop to associate with the socket; defaults to the default loop.
Returns
A shared_ptr owning the newly created socket.
{#convertverificationmode}
convertVerificationMode
inline
inline SSLContext::VerificationMode convertVerificationMode(const std::string & vMode)
Non-case sensitive conversion of a string to a VerificationMode enum. If verMode is illegal an ArgumentException is thrown.
{#convertcertificateerror}
convertCertificateError
inline
inline std::string convertCertificateError(long errCode)
Converts an SSL certificate handling error code into an error message.
{#getlasterror}
getLastError
inline
inline std::string getLastError()
Returns the last error from the error stack.
{#clearerrorstack}
clearErrorStack
inline
inline void clearErrorStack()
Clears the error stack.
{#getnetworkinterfaces}
getNetworkInterfaces
inline
inline void getNetworkInterfaces(std::vector< net::Address > & hosts)
Populates hosts with all local network interface addresses.
Each entry is an IPv4 address constructed from the interface's address4 field. The results include loopback and any other active interfaces reported by libuv.
Parameters
hostsVector to append the discovered addresses to.
{#getserversocketsendbufsize}
getServerSocketSendBufSize
template<typename T> int getServerSocketSendBufSize(uv::Handle< T > & handle)
Returns the current send buffer size for a socket handle, in bytes. Passes val=0 to uv_send_buffer_size, which queries rather than sets the value.
Parameters
TThe libuv handle type (e.g. uv_tcp_t, uv_udp_t).
Parameters
handleThe socket handle to query.
Returns
The send buffer size, or a libuv error code on failure.
{#getserversocketrecvbufsize}
getServerSocketRecvBufSize
template<typename T> int getServerSocketRecvBufSize(uv::Handle< T > & handle)
Returns the current receive buffer size for a socket handle, in bytes. Passes val=0 to uv_recv_buffer_size, which queries rather than sets the value.
Parameters
TThe libuv handle type (e.g. uv_tcp_t, uv_udp_t).
Parameters
handleThe socket handle to query.
Returns
The receive buffer size, or a libuv error code on failure.
{#setserversocketsendbufsize}
setServerSocketSendBufSize
template<typename T> int setServerSocketSendBufSize(uv::Handle< T > & handle, int size)
Sets the send buffer size for a socket handle.
Parameters
TThe libuv handle type (e.g. uv_tcp_t, uv_udp_t).
Parameters
-
handleThe socket handle to configure. -
sizeThe desired send buffer size in bytes.
Returns
0 on success, or a libuv error code on failure.
{#setserversocketrecvbufsize}
setServerSocketRecvBufSize
template<typename T> int setServerSocketRecvBufSize(uv::Handle< T > & handle, int size)
Sets the receive buffer size for a socket handle.
Parameters
TThe libuv handle type (e.g. uv_tcp_t, uv_udp_t).
Parameters
-
handleThe socket handle to configure. -
sizeThe desired receive buffer size in bytes.
Returns
0 on success, or a libuv error code on failure.
Variables
| Return | Name | Description |
|---|---|---|
int | MAX_TCP_PACKET_SIZE constexpr | Maximum size of a single TCP receive buffer, in bytes. |
int | MAX_UDP_PACKET_SIZE constexpr | Maximum size of a single UDP datagram payload, in bytes. |
{#max_tcp_packet_size}
MAX_TCP_PACKET_SIZE
constexpr
int MAX_TCP_PACKET_SIZE = 64 * 1024
Maximum size of a single TCP receive buffer, in bytes.
{#max_udp_packet_size}
MAX_UDP_PACKET_SIZE
constexpr
int MAX_UDP_PACKET_SIZE = 1500
Maximum size of a single UDP datagram payload, in bytes.
{#address}
Address
#include <icy/net/address.h>
class Address
Defined in src/net/include/icy/net/address.h:28
Represents an IPv4 or IPv6 socket address with host and port.
List of all members
| Name | Kind | Owner |
|---|---|---|
operator<< | friend | Declared here |
Address | function | Declared here |
Address | function | Declared here |
Address | function | Declared here |
Address | function | Declared here |
Address | function | Declared here |
Address | function | Declared here |
~Address | function | Declared here |
operator= | function | Declared here |
swap | function | Declared here |
host | function | Declared here |
port | function | Declared here |
length | function | Declared here |
addr | function | Declared here |
af | function | Declared here |
toString | function | Declared here |
family | function | Declared here |
valid | function | Declared here |
operator< | function | Declared here |
operator== | function | Declared here |
operator!= | function | Declared here |
resolveService | function | Declared here |
validateIP | function | Declared here |
init | function | Declared here |
Family | enum | Declared here |
_base | variable | Declared here |
Friends
| Name | Description |
|---|---|
operator<< inline |
{#operator-4}
operator<<
inline
friend inline std::ostream & operator<<(std::ostream & stream, const Address & addr)
Defined in src/net/include/icy/net/address.h:131
Public Methods
| Return | Name | Description |
|---|---|---|
Address | Creates a wildcard (all zero) IPv4 Address. | |
Address | Creates an Address from an IP address and a port number. | |
Address | Creates an Address by copying another one. | |
Address | Creates an Address from a native socket address. | |
Address | Creates an Address from an IP address and a service name or port number. | |
Address explicit | Creates an Address from an IP address or host name and a port number/service name. Host name/address and port number must be separated by a colon. In case of an IPv6 address, the address part must be enclosed in brackets. | |
~Address noexcept | Destroys the Address. | |
Address & | operator= | Assigns another Address. |
void | swap | Swaps the Address with another one. |
std::string | host const | Returns the host IP address. |
uint16_t | port const | Returns the port number. |
socklen_t | length const | Returns the length of the internal native socket address. |
const struct sockaddr * | addr const | Returns a pointer to the internal native socket address. |
int | af const | Returns the address family (AF_INET or AF_INET6) of the address. |
std::string | toString const | Returns a string representation of the address. |
Address::Family | family const | Returns the address family of the host's address. |
bool | valid const | Returns true when the port is set and the address is valid ie. not wildcard. |
bool | operator< const | Compares two addresses for ordering (by family then port). |
bool | operator== const | Returns true if the host and port of both addresses are equal. |
bool | operator!= const | Returns true if the host or port of the addresses differ. |
{#address-1}
Address
Address()
Defined in src/net/include/icy/net/address.h:39
Creates a wildcard (all zero) IPv4 Address.
{#address-2}
Address
Address(const std::string & host, uint16_t port)
Defined in src/net/include/icy/net/address.h:45
Creates an Address from an IP address and a port number.
The IP address must either be a domain name, or it must be in dotted decimal (IPv4) or hex string (IPv6) format.
{#address-3}
Address
Address(const Address & addr)
Defined in src/net/include/icy/net/address.h:48
Creates an Address by copying another one.
{#address-4}
Address
Address(const struct sockaddr * addr, socklen_t length)
Defined in src/net/include/icy/net/address.h:51
Creates an Address from a native socket address.
{#address-5}
Address
Address(const std::string & host, const std::string & port)
Defined in src/net/include/icy/net/address.h:61
Creates an Address from an IP address and a service name or port number.
The IP address must either be a domain name, or it must be in dotted decimal (IPv4) or hex string (IPv6) format.
The given port must either be a decimal port number, or a service name.
{#address-6}
Address
explicit
explicit Address(const std::string & hostAndPort)
Defined in src/net/include/icy/net/address.h:72
Creates an Address from an IP address or host name and a port number/service name. Host name/address and port number must be separated by a colon. In case of an IPv6 address, the address part must be enclosed in brackets.
Examples: 192.168.1.10:80
0state.com:8080
{#address-7}
~Address
noexcept
~Address() noexcept
Defined in src/net/include/icy/net/address.h:75
Destroys the Address.
{#operator-5}
operator=
Address & operator=(const Address & addr)
Defined in src/net/include/icy/net/address.h:78
Assigns another Address.
{#swap}
swap
void swap(Address & addr)
Defined in src/net/include/icy/net/address.h:81
Swaps the Address with another one.
{#host}
host
const
std::string host() const
Defined in src/net/include/icy/net/address.h:84
Returns the host IP address.
{#port}
port
const
uint16_t port() const
Defined in src/net/include/icy/net/address.h:87
Returns the port number.
{#length}
length
const
socklen_t length() const
Defined in src/net/include/icy/net/address.h:90
Returns the length of the internal native socket address.
{#addr-1}
addr
const
const struct sockaddr * addr() const
Defined in src/net/include/icy/net/address.h:93
Returns a pointer to the internal native socket address.
{#af}
af
const
int af() const
Defined in src/net/include/icy/net/address.h:96
Returns the address family (AF_INET or AF_INET6) of the address.
{#tostring-4}
toString
const
std::string toString() const
Defined in src/net/include/icy/net/address.h:99
Returns a string representation of the address.
{#family}
family
const
Address::Family family() const
Defined in src/net/include/icy/net/address.h:102
Returns the address family of the host's address.
{#valid}
valid
const
bool valid() const
Defined in src/net/include/icy/net/address.h:106
Returns true when the port is set and the address is valid ie. not wildcard.
{#operator-6}
operator<
const
bool operator<(const Address & addr) const
Defined in src/net/include/icy/net/address.h:121
Compares two addresses for ordering (by family then port).
Parameters
addrThe address to compare against.
Returns
true if this address is less than addr.
{#operator-7}
operator==
const
bool operator==(const Address & addr) const
Defined in src/net/include/icy/net/address.h:125
Returns true if the host and port of both addresses are equal.
Parameters
addrThe address to compare against.
{#operator-8}
operator!=
const
bool operator!=(const Address & addr) const
Defined in src/net/include/icy/net/address.h:129
Returns true if the host or port of the addresses differ.
Parameters
addrThe address to compare against.
Public Static Methods
| Return | Name | Description |
|---|---|---|
uint16_t | resolveService static | Resolves a service name or decimal port string to a port number. |
bool | validateIP static | Returns true if the given string is a valid IPv4 or IPv6 address. |
{#resolveservice}
resolveService
static
static uint16_t resolveService(const std::string & service)
Defined in src/net/include/icy/net/address.h:111
Resolves a service name or decimal port string to a port number.
Parameters
serviceService name (e.g. "http") or decimal port string (e.g. "80").
Returns
The resolved port number in host byte order.
{#validateip}
validateIP
static
static bool validateIP(std::string_view address)
Defined in src/net/include/icy/net/address.h:116
Returns true if the given string is a valid IPv4 or IPv6 address.
Parameters
addressThe string to validate.
Returns
true if the address parses as a valid IP address, false otherwise.
Protected Methods
| Return | Name | Description |
|---|---|---|
void | init |
{#init-3}
init
void init(const std::string & host, uint16_t port)
Defined in src/net/include/icy/net/address.h:138
Public Types
| Name | Description |
|---|---|
Family | Possible address families for IP addresses. |
{#family-1}
Family
enum Family
Defined in src/net/include/icy/net/address.h:32
Possible address families for IP addresses.
| Value | Description |
|---|---|
IPv4 | |
IPv6 |
Private Attributes
| Return | Name | Description |
|---|---|---|
std::shared_ptr< AddressBase > | _base |
{#_base}
_base
std::shared_ptr< AddressBase > _base
Defined in src/net/include/icy/net/address.h:141
{#packetsocketemitter}
PacketSocketEmitter
#include <icy/net/packetsocket.h>
class PacketSocketEmitter
Defined in src/net/include/icy/net/packetsocket.h:32
Inherits:
SocketEmitter,Signal< void(IPacket &)>Subclassed by:Transaction< Message >,Transaction< PacketT >
Socket adapter that emits received data as packets.
List of all members
| Name | Kind | Owner |
|---|---|---|
factory | variable | Declared here |
PacketSocketEmitter | function | Declared here |
onSocketRecv | function | Declared here |
onPacket | function | Declared here |
Connect | variable | Inherited from SocketEmitter |
Recv | variable | Inherited from SocketEmitter |
Error | variable | Inherited from SocketEmitter |
Close | variable | Inherited from SocketEmitter |
impl | variable | Inherited from SocketEmitter |
SocketEmitter | function | Inherited from SocketEmitter |
SocketEmitter | function | Inherited from SocketEmitter |
~SocketEmitter | function | Inherited from SocketEmitter |
addReceiver | function | Inherited from SocketEmitter |
removeReceiver | function | Inherited from SocketEmitter |
swap | function | Inherited from SocketEmitter |
as | function | Inherited from SocketEmitter |
operator-> | function | Inherited from SocketEmitter |
onSocketConnect | function | Inherited from SocketEmitter |
onSocketRecv | function | Inherited from SocketEmitter |
onSocketError | function | Inherited from SocketEmitter |
onSocketClose | function | Inherited from SocketEmitter |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from SocketEmitter
| Kind | Name | Description |
|---|---|---|
variable | Connect | Signals that the socket is connected. |
variable | Recv | Signals when data is received by the socket. |
variable | Error | Signals that the socket is closed in error. This signal will be sent just before the Closed signal. |
variable | Close | Signals that the underlying socket is closed. |
variable | impl | Pointer to the underlying socket. Sent data will be proxied to this socket. |
function | SocketEmitter | Creates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver. |
function | SocketEmitter | Copy constructor; copies all signal connections and attaches to the same socket. |
function | ~SocketEmitter virtual noexcept | Destroys the SocketAdapter. |
function | addReceiver virtual override | Attaches a SocketAdapter as a receiver; wires it to all four socket signals. |
function | removeReceiver virtual override | Detaches a SocketAdapter from all four socket signals. |
function | swap virtual | Replaces the underlying socket with socket. |
function | as inline | Returns the underlying socket cast to type T, or nullptr if the cast fails. |
function | operator-> const inline | Returns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer. |
function | onSocketConnect virtual override | Forwards the connect event to chained adapters, then fires the Connect signal. |
function | onSocketRecv virtual override | Forwards the recv event to chained adapters, then fires the Recv signal. |
function | onSocketError virtual override | Forwards the error event to chained adapters, then fires the Error signal. |
function | onSocketClose virtual override | Forwards the close event to chained adapters, then fires the Close signal. |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Public Attributes
| Return | Name | Description |
|---|---|---|
PacketFactory | factory | The packet factory. |
{#factory}
factory
PacketFactory factory
Defined in src/net/include/icy/net/packetsocket.h:59
The packet factory.
Public Methods
| Return | Name | Description |
|---|---|---|
PacketSocketEmitter | Creates the PacketSocketEmitter and attaches it to the given socket. | |
bool | onSocketRecv virtual override | Parses raw received data into packets via the factory and forwards each parsed packet to onPacket(). Returns true if propagation should stop. |
bool | onPacket virtual | Process a parsed packet. Returns true to stop propagation. |
{#packetsocketemitter-1}
PacketSocketEmitter
PacketSocketEmitter(const Socket::Ptr & socket = nullptr)
Defined in src/net/include/icy/net/packetsocket.h:43
Creates the PacketSocketEmitter and attaches it to the given socket.
The emitter should be assigned a higher priority than plain socket adapters so that packet parsing occurs before generic data callbacks. Packets are created and dispatched using the registered factory strategies; strategies with the highest priority are tried first.
Parameters
socketOptional socket to attach to immediately.
{#onsocketrecv}
onSocketRecv
virtual override
virtual bool onSocketRecv(Socket & socket, const MutableBuffer & buffer, const Address & peerAddress) override
Defined in src/net/include/icy/net/packetsocket.h:53
Parses raw received data into packets via the factory and forwards each parsed packet to onPacket(). Returns true if propagation should stop.
Parameters
-
socketThe socket that received the data. -
bufferThe raw received data buffer. -
peerAddressThe sender's address.
Returns
true if the event was consumed and should not propagate further.
Reimplements
{#onpacket}
onPacket
virtual
virtual bool onPacket(IPacket & pkt)
Defined in src/net/include/icy/net/packetsocket.h:56
Process a parsed packet. Returns true to stop propagation.
Reimplemented by
{#socket-1}
Socket
#include <icy/net/socket.h>
class Socket
Defined in src/net/include/icy/net/socket.h:49
Inherits:
SocketAdapterSubclassed by:TCPSocket,UDPSocket
Base socket implementation from which all sockets derive.
List of all members
| Name | Kind | Owner |
|---|---|---|
opaque | variable | Declared here |
Socket | function | Declared here |
Socket | function | Declared here |
Socket | function | Declared here |
connect | function | Declared here |
connect | function | Declared here |
bind | function | Declared here |
listen | function | Declared here |
shutdown | function | Declared here |
sendOwned | function | Declared here |
sendOwned | function | Declared here |
close | function | Declared here |
address | function | Declared here |
peerAddress | function | Declared here |
transport | function | Declared here |
setError | function | Declared here |
error | function | Declared here |
closed | function | Declared here |
loop | function | Declared here |
_af | variable | Declared here |
init | function | Declared here |
reset | function | Declared here |
Ptr | typedef | Declared here |
Vec | typedef | Declared here |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Public Attributes
| Return | Name | Description |
|---|---|---|
std::any | opaque | Optional client data. |
{#opaque}
opaque
std::any opaque
Defined in src/net/include/icy/net/socket.h:135
Optional client data.
The value is empty on initialization.
Public Methods
| Return | Name | Description |
|---|---|---|
Socket | Defaulted constructor. | |
Socket | Deleted constructor. | |
Socket | Deleted constructor. | |
void | connect virtual | Connects to the given peer IP address. |
void | connect virtual | Resolves and connects to the given host address. |
void | bind virtual | Bind a local address to the socket. The address may be IPv4 or IPv6 (if supported). |
void | listen virtual inline | Listens the socket on the given address. |
bool | shutdown virtual inline nodiscard | Sends the shutdown packet which should result is socket closure via callback. |
ssize_t | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
ssize_t | sendOwned virtual nodiscard | |
void | close virtual | Closes the underlying socket. |
Address | address virtual const | The locally bound address. |
Address | peerAddress virtual const | The connected peer address. |
net::TransportType | transport virtual const | The transport protocol: TCP, UDP or SSLTCP. |
void | setError virtual | Sets the socket error. |
const icy::Error & | error virtual const | Return the socket error if any. |
bool | closed virtual const | Returns true if the native socket handle is closed. |
uv::Loop * | loop virtual const | Returns the socket event loop. |
{#socket-2}
Socket
Socket() = default
Defined in src/net/include/icy/net/socket.h:55
Defaulted constructor.
{#socket-3}
Socket
Socket(const Socket &) = delete
Defined in src/net/include/icy/net/socket.h:58
Deleted constructor.
{#socket-4}
Socket
Socket(Socket &&) = delete
Defined in src/net/include/icy/net/socket.h:60
Deleted constructor.
{#connect-2}
connect
virtual
virtual void connect(const Address & address)
Defined in src/net/include/icy/net/socket.h:67
Connects to the given peer IP address.
Throws an exception if the address is malformed. Connection errors can be handled via the Error signal.
Reimplemented by
{#connect-3}
connect
virtual
virtual void connect(std::string_view host, uint16_t port)
Defined in src/net/include/icy/net/socket.h:74
Resolves and connects to the given host address.
Throws an Exception if the host is malformed. Since the DNS callback is asynchronous implementations need to listen for the Error signal for handling connection errors.
Reimplemented by
{#bind}
bind
virtual
virtual void bind(const Address & address, unsigned flags = 0)
Defined in src/net/include/icy/net/socket.h:80
Bind a local address to the socket. The address may be IPv4 or IPv6 (if supported).
Throws an Exception on error.
Reimplemented by
{#listen}
listen
virtual inline
virtual inline void listen(int backlog = 64)
Defined in src/net/include/icy/net/socket.h:85
Listens the socket on the given address.
Throws an Exception on error.
Reimplemented by
{#shutdown-1}
shutdown
virtual inline nodiscard
[[nodiscard]] virtual inline bool shutdown()
Defined in src/net/include/icy/net/socket.h:89
Sends the shutdown packet which should result is socket closure via callback.
Reimplemented by
{#sendowned}
sendOwned
virtual nodiscard
[[nodiscard]] virtual ssize_t sendOwned(Buffer && buffer, int flags = 0)
Defined in src/net/include/icy/net/socket.h:95
Sends an owned payload buffer to the connected peer.
Reimplements
Reimplemented by
{#sendowned-1}
sendOwned
virtual nodiscard
[[nodiscard]] virtual ssize_t sendOwned(Buffer && buffer, const Address & peerAddress, int flags = 0)
Defined in src/net/include/icy/net/socket.h:96
Reimplements
Reimplemented by
{#close-12}
close
virtual
virtual void close()
Defined in src/net/include/icy/net/socket.h:99
Closes the underlying socket.
Reimplemented by
{#address-8}
address
virtual const
virtual Address address() const
Defined in src/net/include/icy/net/socket.h:106
The locally bound address.
This function will not throw. A Wildcard 0.0.0.0:0 address is returned if the socket is closed or invalid.
Reimplemented by
{#peeraddress-1}
peerAddress
virtual const
virtual Address peerAddress() const
Defined in src/net/include/icy/net/socket.h:113
The connected peer address.
This function will not throw. A Wildcard 0.0.0.0:0 address is returned if the socket is closed or invalid.
Reimplemented by
{#transport}
transport
virtual const
virtual net::TransportType transport() const
Defined in src/net/include/icy/net/socket.h:116
The transport protocol: TCP, UDP or SSLTCP.
Reimplemented by
{#seterror-1}
setError
virtual
virtual void setError(const icy::Error & err)
Defined in src/net/include/icy/net/socket.h:121
Sets the socket error.
Setting the error will result in socket closure.
Reimplemented by
{#error-5}
error
virtual const
virtual const icy::Error & error() const
Defined in src/net/include/icy/net/socket.h:124
Return the socket error if any.
Reimplemented by
{#closed-1}
closed
virtual const
virtual bool closed() const
Defined in src/net/include/icy/net/socket.h:127
Returns true if the native socket handle is closed.
Reimplemented by
{#loop-3}
loop
virtual const
virtual uv::Loop * loop() const
Defined in src/net/include/icy/net/socket.h:130
Returns the socket event loop.
Reimplemented by
Protected Attributes
| Return | Name | Description |
|---|---|---|
int | _af |
{#_af}
_af
int _af {AF_UNSPEC}
Defined in src/net/include/icy/net/socket.h:144
Protected Methods
| Return | Name | Description |
|---|---|---|
void | init virtual | Initializes the underlying socket context. |
void | reset virtual | Resets the socket context for reuse. |
{#init-4}
init
virtual
virtual void init()
Defined in src/net/include/icy/net/socket.h:139
Initializes the underlying socket context.
Reimplemented by
{#reset-4}
reset
virtual
virtual void reset()
Defined in src/net/include/icy/net/socket.h:142
Resets the socket context for reuse.
Reimplemented by
Public Types
| Name | Description |
|---|---|
Ptr | |
Vec |
{#ptr-4}
Ptr
using Ptr = std::shared_ptr< Socket >
Defined in src/net/include/icy/net/socket.h:52
{#vec}
Vec
using Vec = std::vector< Ptr >
Defined in src/net/include/icy/net/socket.h:53
{#socketadapter}
SocketAdapter
#include <icy/net/socketadapter.h>
class SocketAdapter
Defined in src/net/include/icy/net/socketadapter.h:41
Subclassed by:
Connection,ConnectionAdapter,ConnectionStream,Server,Socket,SocketEmitter
Abstract adapter interface for socket send/receive chains.
SocketAdapter is the abstract interface for all socket classes. A SocketAdapter can also be attached to a Socket in order to override default Socket callbacks and behaviour, while still maintaining the default Socket interface (see Socket::setAdapter).
This class can also be extended to implement custom processing for received socket data before it is dispatched to the application (see PacketSocketEmitter and Transaction classes).
List of all members
| Name | Kind | Owner |
|---|---|---|
priority | variable | Declared here |
SocketAdapter | function | Declared here |
~SocketAdapter | function | Declared here |
send | function | Declared here |
send | function | Declared here |
sendOwned | function | Declared here |
sendOwned | function | Declared here |
sendPacket | function | Declared here |
sendPacket | function | Declared here |
sendPacket | function | Declared here |
setSender | function | Declared here |
sender | function | Declared here |
addReceiver | function | Declared here |
removeReceiver | function | Declared here |
hasReceiver | function | Declared here |
receivers | function | Declared here |
onSocketConnect | function | Declared here |
onSocketRecv | function | Declared here |
onSocketError | function | Declared here |
onSocketClose | function | Declared here |
_sender | variable | Declared here |
_receivers | variable | Declared here |
_dirty | variable | Declared here |
cleanupReceivers | function | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
int | priority | The priority of this adapter for STL sort operations. |
{#priority-1}
priority
int priority = 0
Defined in src/net/include/icy/net/socketadapter.h:132
The priority of this adapter for STL sort operations.
Public Methods
| Return | Name | Description |
|---|---|---|
SocketAdapter | Creates the SocketAdapter. | |
~SocketAdapter virtual noexcept | Destroys the SocketAdapter. | |
ssize_t | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
ssize_t | send virtual nodiscard | |
ssize_t | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
ssize_t | sendOwned virtual nodiscard | |
ssize_t | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
ssize_t | sendPacket virtual | |
void | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
void | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
SocketAdapter * | sender | Returns the output SocketAdapter pointer. |
void | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
void | removeReceiver virtual | Remove the given receiver. |
bool | hasReceiver virtual | Returns true if the given receiver is connected. |
std::vector< SocketAdapter * > | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
bool | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
bool | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
bool | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
bool | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
{#socketadapter-1}
SocketAdapter
SocketAdapter(SocketAdapter * sender = nullptr)
Defined in src/net/include/icy/net/socketadapter.h:45
Creates the SocketAdapter.
{#socketadapter-2}
~SocketAdapter
virtual noexcept
virtual ~SocketAdapter() noexcept
Defined in src/net/include/icy/net/socketadapter.h:48
Destroys the SocketAdapter.
{#send}
send
virtual nodiscard
[[nodiscard]] virtual ssize_t send(const char * data, size_t len, int flags = 0)
Defined in src/net/include/icy/net/socketadapter.h:55
Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address.
Reimplemented by
{#send-1}
send
virtual nodiscard
[[nodiscard]] virtual ssize_t send(const char * data, size_t len, const Address & peerAddress, int flags = 0)
Defined in src/net/include/icy/net/socketadapter.h:56
Reimplemented by
{#sendowned-2}
sendOwned
virtual nodiscard
[[nodiscard]] virtual ssize_t sendOwned(Buffer && buffer, int flags = 0)
Defined in src/net/include/icy/net/socketadapter.h:62
Sends an owned payload buffer to the connected peer.
The buffer is moved through the adapter chain and retained by the transport layer until async write completion.
Reimplemented by
{#sendowned-3}
sendOwned
virtual nodiscard
[[nodiscard]] virtual ssize_t sendOwned(Buffer && buffer, const Address & peerAddress, int flags = 0)
Defined in src/net/include/icy/net/socketadapter.h:63
Reimplemented by
{#sendpacket}
sendPacket
virtual
virtual ssize_t sendPacket(const IPacket & packet, int flags = 0)
Defined in src/net/include/icy/net/socketadapter.h:70
Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address.
{#sendpacket-1}
sendPacket
virtual
virtual ssize_t sendPacket(const IPacket & packet, const Address & peerAddress, int flags = 0)
Defined in src/net/include/icy/net/socketadapter.h:71
{#sendpacket-2}
sendPacket
virtual
virtual void sendPacket(IPacket & packet)
Defined in src/net/include/icy/net/socketadapter.h:77
Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed.
{#setsender}
setSender
virtual
virtual void setSender(SocketAdapter * adapter)
Defined in src/net/include/icy/net/socketadapter.h:81
Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
{#sender}
sender
SocketAdapter * sender()
Defined in src/net/include/icy/net/socketadapter.h:84
Returns the output SocketAdapter pointer.
{#addreceiver}
addReceiver
virtual
virtual void addReceiver(SocketAdapter * adapter)
Defined in src/net/include/icy/net/socketadapter.h:88
Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
Reimplemented by
{#removereceiver}
removeReceiver
virtual
virtual void removeReceiver(SocketAdapter * adapter)
Defined in src/net/include/icy/net/socketadapter.h:94
Remove the given receiver.
By default this function does nothing unless the given receiver matches the current receiver.
Reimplemented by
{#hasreceiver}
hasReceiver
virtual
virtual bool hasReceiver(SocketAdapter * adapter)
Defined in src/net/include/icy/net/socketadapter.h:97
Returns true if the given receiver is connected.
{#receivers}
receivers
std::vector< SocketAdapter * > receivers()
Defined in src/net/include/icy/net/socketadapter.h:101
Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
{#onsocketconnect}
onSocketConnect
virtual
virtual bool onSocketConnect(Socket & socket)
Defined in src/net/include/icy/net/socketadapter.h:108
Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event.
Parameters
socketThe connected socket.
Returns
true to stop propagation to subsequent receivers.
Reimplemented by
{#onsocketrecv-1}
onSocketRecv
virtual
virtual bool onSocketRecv(Socket & socket, const MutableBuffer & buffer, const Address & peerAddress)
Defined in src/net/include/icy/net/socketadapter.h:116
Called when data is received from the socket. Forwards the event to all registered receivers in priority order.
Parameters
-
socketThe socket that received data. -
bufferThe received data buffer. -
peerAddressAddress of the sender.
Returns
true to stop propagation to subsequent receivers.
Reimplemented by
{#onsocketerror}
onSocketError
virtual
virtual bool onSocketError(Socket & socket, const Error & error)
Defined in src/net/include/icy/net/socketadapter.h:123
Called when the socket encounters an error. Forwards the event to all registered receivers in priority order.
Parameters
-
socketThe socket that encountered the error. -
errorError details.
Returns
true to stop propagation to subsequent receivers.
Reimplemented by
{#onsocketclose}
onSocketClose
virtual
virtual bool onSocketClose(Socket & socket)
Defined in src/net/include/icy/net/socketadapter.h:129
Called when the socket is closed. Forwards the event to all registered receivers in priority order.
Parameters
socketThe socket that was closed.
Returns
true to stop propagation to subsequent receivers.
Reimplemented by
Protected Attributes
| Return | Name | Description |
|---|---|---|
SocketAdapter * | _sender | |
std::vector< Ref > | _receivers | |
bool | _dirty |
{#_sender}
_sender
SocketAdapter * _sender
Defined in src/net/include/icy/net/socketadapter.h:144
{#_receivers}
_receivers
std::vector< Ref > _receivers
Defined in src/net/include/icy/net/socketadapter.h:145
{#_dirty}
_dirty
bool _dirty = false
Defined in src/net/include/icy/net/socketadapter.h:146
Protected Methods
| Return | Name | Description |
|---|---|---|
void | cleanupReceivers virtual |
{#cleanupreceivers}
cleanupReceivers
virtual
virtual void cleanupReceivers()
Defined in src/net/include/icy/net/socketadapter.h:135
{#ref-1}
Ref
#include <icy/net/socketadapter.h>
struct Ref
Defined in src/net/include/icy/net/socketadapter.h:138
Reference-counted handle to a SocketAdapter.
List of all members
| Name | Kind | Owner |
|---|---|---|
ptr | variable | Declared here |
alive | variable | Declared here |
Public Attributes
| Return | Name | Description |
|---|---|---|
SocketAdapter * | ptr | |
bool | alive |
{#ptr-5}
ptr
SocketAdapter * ptr
Defined in src/net/include/icy/net/socketadapter.h:140
{#alive}
alive
bool alive
Defined in src/net/include/icy/net/socketadapter.h:141
{#socketemitter}
SocketEmitter
#include <icy/net/socketemitter.h>
class SocketEmitter
Defined in src/net/include/icy/net/socketemitter.h:32
Inherits:
SocketAdapterSubclassed by:WebSocketAdapter,PacketSocketEmitter
SocketAdapter that exposes socket events as signals.
Aside from adding a signal interface, the class wraps the underlying socket instance and is designed to be used much like a std::unique_ptr by overriding the -> operator.
List of all members
| Name | Kind | Owner |
|---|---|---|
Connect | variable | Declared here |
Recv | variable | Declared here |
Error | variable | Declared here |
Close | variable | Declared here |
impl | variable | Declared here |
SocketEmitter | function | Declared here |
SocketEmitter | function | Declared here |
~SocketEmitter | function | Declared here |
addReceiver | function | Declared here |
removeReceiver | function | Declared here |
swap | function | Declared here |
as | function | Declared here |
operator-> | function | Declared here |
onSocketConnect | function | Declared here |
onSocketRecv | function | Declared here |
onSocketError | function | Declared here |
onSocketClose | function | Declared here |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Public Attributes
| Return | Name | Description |
|---|---|---|
LocalSignal< bool(Socket &)> | Connect | Signals that the socket is connected. |
LocalSignal< bool(Socket &, const MutableBuffer &, const Address &)> | Recv | Signals when data is received by the socket. |
LocalSignal< bool(Socket &, const icy::Error &)> | Error | Signals that the socket is closed in error. This signal will be sent just before the Closed signal. |
LocalSignal< bool(Socket &)> | Close | Signals that the underlying socket is closed. |
Socket::Ptr | impl | Pointer to the underlying socket. Sent data will be proxied to this socket. |
{#connect-4}
Connect
LocalSignal< bool(Socket &)> Connect
Defined in src/net/include/icy/net/socketemitter.h:48
Signals that the socket is connected.
{#recv}
Recv
LocalSignal< bool(Socket &, const MutableBuffer &, const Address &)> Recv
Defined in src/net/include/icy/net/socketemitter.h:51
Signals when data is received by the socket.
{#error-6}
Error
LocalSignal< bool(Socket &, const icy::Error &)> Error
Defined in src/net/include/icy/net/socketemitter.h:56
Signals that the socket is closed in error. This signal will be sent just before the Closed signal.
{#close-13}
Close
LocalSignal< bool(Socket &)> Close
Defined in src/net/include/icy/net/socketemitter.h:59
Signals that the underlying socket is closed.
{#impl}
impl
Socket::Ptr impl
Defined in src/net/include/icy/net/socketemitter.h:94
Pointer to the underlying socket. Sent data will be proxied to this socket.
Public Methods
| Return | Name | Description |
|---|---|---|
SocketEmitter | Creates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver. | |
SocketEmitter | Copy constructor; copies all signal connections and attaches to the same socket. | |
~SocketEmitter virtual noexcept | Destroys the SocketAdapter. | |
void | addReceiver virtual override | Attaches a SocketAdapter as a receiver; wires it to all four socket signals. |
void | removeReceiver virtual override | Detaches a SocketAdapter from all four socket signals. |
void | swap virtual | Replaces the underlying socket with socket. |
T * | as inline | Returns the underlying socket cast to type T, or nullptr if the cast fails. |
Socket * | operator-> const inline | Returns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer. |
{#socketemitter-1}
SocketEmitter
SocketEmitter(const Socket::Ptr & socket = nullptr)
Defined in src/net/include/icy/net/socketemitter.h:38
Creates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver.
Parameters
socketOptional socket to attach to; pass nullptr to attach later via swap().
{#socketemitter-2}
SocketEmitter
SocketEmitter(const SocketEmitter & that)
Defined in src/net/include/icy/net/socketemitter.h:42
Copy constructor; copies all signal connections and attaches to the same socket.
Parameters
thatThe SocketEmitter to copy from.
{#socketemitter-3}
~SocketEmitter
virtual noexcept
virtual ~SocketEmitter() noexcept
Defined in src/net/include/icy/net/socketemitter.h:45
Destroys the SocketAdapter.
{#addreceiver-1}
addReceiver
virtual override
virtual void addReceiver(SocketAdapter * adapter) override
Defined in src/net/include/icy/net/socketemitter.h:63
Attaches a SocketAdapter as a receiver; wires it to all four socket signals.
Parameters
adapterThe adapter to attach; its priority determines signal ordering.
Reimplements
{#removereceiver-1}
removeReceiver
virtual override
virtual void removeReceiver(SocketAdapter * adapter) override
Defined in src/net/include/icy/net/socketemitter.h:67
Detaches a SocketAdapter from all four socket signals.
Parameters
adapterThe adapter to detach.
Reimplements
{#swap-1}
swap
virtual
virtual void swap(const Socket::Ptr & socket)
Defined in src/net/include/icy/net/socketemitter.h:73
Replaces the underlying socket with socket.
Throws std::logic_error if the emitter already has an attached socket.
Parameters
socketThe new socket to attach.
{#as}
as
inline
template<class T> inline T * as()
Defined in src/net/include/icy/net/socketemitter.h:79
Returns the underlying socket cast to type T, or nullptr if the cast fails.
Parameters
TDerived socket type to cast to.
Returns
Pointer to the socket as T, or nullptr on type mismatch.
{#operator-9}
operator->
const inline
inline Socket * operator->() const
Defined in src/net/include/icy/net/socketemitter.h:87
Returns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer.
Returns
Raw pointer to the socket (never null if a socket was attached).
Protected Methods
| Return | Name | Description |
|---|---|---|
bool | onSocketConnect virtual override | Forwards the connect event to chained adapters, then fires the Connect signal. |
bool | onSocketRecv virtual override | Forwards the recv event to chained adapters, then fires the Recv signal. |
bool | onSocketError virtual override | Forwards the error event to chained adapters, then fires the Error signal. |
bool | onSocketClose virtual override | Forwards the close event to chained adapters, then fires the Close signal. |
{#onsocketconnect-1}
onSocketConnect
virtual override
virtual bool onSocketConnect(Socket & socket) override
Defined in src/net/include/icy/net/socketemitter.h:98
Forwards the connect event to chained adapters, then fires the Connect signal.
Reimplements
Reimplemented by
{#onsocketrecv-2}
onSocketRecv
virtual override
virtual bool onSocketRecv(Socket & socket, const MutableBuffer & buffer, const Address & peerAddress) override
Defined in src/net/include/icy/net/socketemitter.h:100
Forwards the recv event to chained adapters, then fires the Recv signal.
Reimplements
Reimplemented by
{#onsocketerror-1}
onSocketError
virtual override
virtual bool onSocketError(Socket & socket, const icy::Error & error) override
Defined in src/net/include/icy/net/socketemitter.h:102
Forwards the error event to chained adapters, then fires the Error signal.
Reimplements
{#onsocketclose-1}
onSocketClose
virtual override
virtual bool onSocketClose(Socket & socket) override
Defined in src/net/include/icy/net/socketemitter.h:104
Forwards the close event to chained adapters, then fires the Close signal.
Reimplements
Reimplemented by
{#socketpacket}
SocketPacket
#include <icy/net/socket.h>
class SocketPacket
Defined in src/net/include/icy/net/socket.h:200
Inherits:
RawPacket
Default packet type emitted by sockets.
SocketPacket carries the remote peer address plus a borrowed view of the received byte buffer for zero-copy processing inside the receive callback.
The referenced packet buffer lifetime is only guaranteed for the duration of the receiver callback.
List of all members
| Name | Kind | Owner |
|---|---|---|
SocketPacket | function | Declared here |
SocketPacket | function | Declared here |
packetInfo | function | Declared here |
print | function | Declared here |
clone | function | Declared here |
read | function | Declared here |
write | function | Declared here |
className | function | Declared here |
_data | variable | Inherited from RawPacket |
_size | variable | Inherited from RawPacket |
_owned | variable | Inherited from RawPacket |
RawPacket | function | Inherited from RawPacket |
RawPacket | function | Inherited from RawPacket |
RawPacket | function | Inherited from RawPacket |
~RawPacket | function | Inherited from RawPacket |
clone | function | Inherited from RawPacket |
copyData | function | Inherited from RawPacket |
read | function | Inherited from RawPacket |
write | function | Inherited from RawPacket |
data | function | Inherited from RawPacket |
size | function | Inherited from RawPacket |
className | function | Inherited from RawPacket |
ownsBuffer | function | Inherited from RawPacket |
opaque | variable | Inherited from IPacket |
info | variable | Inherited from IPacket |
flags | variable | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
operator= | function | Inherited from IPacket |
clone | function | Inherited from IPacket |
~IPacket | function | Inherited from IPacket |
read | function | Inherited from IPacket |
write | function | Inherited from IPacket |
size | function | Inherited from IPacket |
hasData | function | Inherited from IPacket |
data | function | Inherited from IPacket |
constData | function | Inherited from IPacket |
className | function | Inherited from IPacket |
print | function | Inherited from IPacket |
operator<< | friend | Inherited from IPacket |
Inherited from RawPacket
| Kind | Name | Description |
|---|---|---|
variable | _data | |
variable | _size | |
variable | _owned | |
function | RawPacket inline | Construct with borrowed (non-owning) buffer. |
function | RawPacket inline | Construct with const data (copied, owning). |
function | RawPacket inline | Copy constructor (always copies data). |
function | ~RawPacket virtual | Defaulted destructor. |
function | clone virtual const inline override | |
function | copyData virtual inline | Copies data into an internally owned buffer, replacing any prior content. |
function | read virtual inline override | Reads from the buffer by copying its contents into an owned buffer. |
function | write virtual const inline override | Appends the packet data to the given output buffer. |
function | data virtual const inline override | |
function | size virtual const inline override | |
function | className virtual const inline override | Returns the class name of this packet type for logging and diagnostics. |
function | ownsBuffer const inline |
Inherited from IPacket
| Kind | Name | Description |
|---|---|---|
variable | opaque | Optional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime. |
variable | info | Optional extra information about the packet. |
variable | flags | Provides basic information about the packet. |
function | IPacket inline | |
function | IPacket inline | Copy constructor; clones the info object if present. |
function | operator= inline | Copy assignment; clones the info object if present. |
function | clone virtual const | Returns a heap-allocated deep copy of this packet. |
function | ~IPacket virtual | Defaulted destructor. |
function | read virtual | Read/parse to the packet from the given input buffer. The number of bytes read is returned. |
function | write virtual const | Copy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer. |
function | size virtual const inline | The size of the packet in bytes. |
function | hasData virtual const inline | Returns true if the packet has a non-null data pointer. |
function | data virtual const inline | The packet data pointer for buffered packets. |
function | constData virtual const inline | The const packet data pointer for buffered packets. |
function | className virtual const | Returns the class name of this packet type for logging and diagnostics. |
function | print virtual const inline | Prints a human-readable representation to the given stream. |
friend | operator<< inline | Stream insertion operator; delegates to print(). |
Public Methods
| Return | Name | Description |
|---|---|---|
SocketPacket inline | Constructs a SocketPacket wrapping the received buffer. | |
SocketPacket inline | Copy constructor; shares the underlying buffer reference. | |
PacketInfo * | packetInfo const inline | Returns the PacketInfo for this socket packet. |
void | print virtual const inline | Prints a one-line description of the packet to os. |
std::unique_ptr< IPacket > | clone virtual const inline | Returns a heap-allocated copy of this SocketPacket. |
ssize_t | read virtual inline | Not supported; always throws std::logic_error. |
void | write virtual const inline | Appends the packet payload to buf. |
const char * | className virtual const inline |
{#socketpacket-1}
SocketPacket
inline
inline SocketPacket(const Socket::Ptr & socket, const MutableBuffer & buffer, const Address & peerAddress)
Defined in src/net/include/icy/net/socket.h:210
Constructs a SocketPacket wrapping the received buffer.
The buffer data pointer remains valid only for the duration of the enclosing receive callback; do not retain references beyond that scope.
Parameters
-
socketShared pointer to the receiving socket. -
bufferView of the raw received bytes. -
peerAddressAddress of the remote sender.
{#socketpacket-2}
SocketPacket
inline
inline SocketPacket(const SocketPacket & that)
Defined in src/net/include/icy/net/socket.h:218
Copy constructor; shares the underlying buffer reference.
Parameters
thatSource SocketPacket to copy.
{#packetinfo-3}
packetInfo
const inline
inline PacketInfo * packetInfo() const
Defined in src/net/include/icy/net/socket.h:225
Returns the PacketInfo for this socket packet.
Returns
Pointer to the associated PacketInfo (never null for a valid packet).
{#print-6}
virtual const inline
virtual inline void print(std::ostream & os) const
Defined in src/net/include/icy/net/socket.h:234
Prints a one-line description of the packet to os.
Parameters
osOutput stream to write to.
Reimplements
{#clone-6}
clone
virtual const inline
virtual inline std::unique_ptr< IPacket > clone() const
Defined in src/net/include/icy/net/socket.h:240
Returns a heap-allocated copy of this SocketPacket.
Reimplements
{#read-1}
read
virtual inline
virtual inline ssize_t read(const ConstBuffer &)
Defined in src/net/include/icy/net/socket.h:243
Not supported; always throws std::logic_error.
Reimplements
{#write-1}
write
virtual const inline
virtual inline void write(Buffer & buf) const
Defined in src/net/include/icy/net/socket.h:251
Appends the packet payload to buf.
Parameters
bufDestination buffer to append raw bytes to.
Reimplements
{#classname-5}
className
virtual const inline
virtual inline const char * className() const
Defined in src/net/include/icy/net/socket.h:258
Returns
The string "SocketPacket".
Reimplements
{#ssladapter}
SSLAdapter
#include <icy/net/ssladapter.h>
class SSLAdapter
Defined in src/net/include/icy/net/ssladapter.h:38
Manages the OpenSSL context and BIO buffers for an SSL socket connection.
List of all members
| Name | Kind | Owner |
|---|---|---|
SSLSocket | friend | Declared here |
SSLAdapter | function | Declared here |
SSLAdapter | function | Declared here |
SSLAdapter | function | Declared here |
initClient | function | Declared here |
initServer | function | Declared here |
initialized | function | Declared here |
ready | function | Declared here |
handshake | function | Declared here |
available | function | Declared here |
shutdown | function | Declared here |
flush | function | Declared here |
setHostname | function | Declared here |
addIncomingData | function | Declared here |
addOutgoingData | function | Declared here |
addOutgoingData | function | Declared here |
addOutgoingData | function | Declared here |
_socket | variable | Declared here |
_ssl | variable | Declared here |
_readBIO | variable | Declared here |
_writeBIO | variable | Declared here |
_bufferOut | variable | Declared here |
_hostname | variable | Declared here |
handleError | function | Declared here |
flushReadBIO | function | Declared here |
flushWriteBIO | function | Declared here |
Friends
| Name | Description |
|---|---|
net::SSLSocket |
{#net-sslsocket}
net::SSLSocket
friend class net::SSLSocket
Defined in src/net/include/icy/net/ssladapter.h:107
Public Methods
| Return | Name | Description |
|---|---|---|
SSLAdapter | Constructs the SSLAdapter and associates it with the given socket. The socket pointer must remain valid for the lifetime of this adapter. | |
SSLAdapter | Deleted constructor. | |
SSLAdapter | Deleted constructor. | |
void | initClient | Initializes the SSL context as a client. |
void | initServer | Initializes the SSL context as a server. |
bool | initialized const | Returns true when SSL context has been initialized. |
bool | ready const | Returns true when the handshake is complete. |
void | handshake | Start/continue the SSL handshake process. |
int | available const | Returns the number of bytes available in the SSL buffer for immediate reading. |
void | shutdown | Issues an orderly SSL shutdown. |
void | flush | Flushes the SSL read/write buffers. |
void | setHostname | Set the expected peer hostname for certificate verification. Must be called before initClient() to enable hostname verification. |
void | addIncomingData | Feeds encrypted data received from the network into the SSL read BIO. Triggers a flush, which drives the handshake or decrypts and delivers plaintext to the socket via onRecv(). |
void | addOutgoingData | Queues plaintext data for encryption and transmission. |
void | addOutgoingData | Queues plaintext data for encryption and transmission. |
void | addOutgoingData | Moves plaintext data into the pending write buffer when possible. |
{#ssladapter-1}
SSLAdapter
SSLAdapter(net::SSLSocket * socket)
Defined in src/net/include/icy/net/ssladapter.h:44
Constructs the SSLAdapter and associates it with the given socket. The socket pointer must remain valid for the lifetime of this adapter.
Parameters
socketThe owning SSLSocket that sends and receives raw data.
{#ssladapter-2}
SSLAdapter
SSLAdapter(const SSLAdapter &) = delete
Defined in src/net/include/icy/net/ssladapter.h:47
Deleted constructor.
{#ssladapter-3}
SSLAdapter
SSLAdapter(SSLAdapter &&) = delete
Defined in src/net/include/icy/net/ssladapter.h:49
Deleted constructor.
{#initclient}
initClient
void initClient()
Defined in src/net/include/icy/net/ssladapter.h:53
Initializes the SSL context as a client.
{#initserver}
initServer
void initServer()
Defined in src/net/include/icy/net/ssladapter.h:56
Initializes the SSL context as a server.
{#initialized-2}
initialized
const
bool initialized() const
Defined in src/net/include/icy/net/ssladapter.h:59
Returns true when SSL context has been initialized.
{#ready}
ready
const
bool ready() const
Defined in src/net/include/icy/net/ssladapter.h:62
Returns true when the handshake is complete.
{#handshake}
handshake
void handshake()
Defined in src/net/include/icy/net/ssladapter.h:65
Start/continue the SSL handshake process.
{#available-1}
available
const
int available() const
Defined in src/net/include/icy/net/ssladapter.h:69
Returns the number of bytes available in the SSL buffer for immediate reading.
{#shutdown-2}
shutdown
void shutdown()
Defined in src/net/include/icy/net/ssladapter.h:72
Issues an orderly SSL shutdown.
{#flush-8}
flush
void flush()
Defined in src/net/include/icy/net/ssladapter.h:75
Flushes the SSL read/write buffers.
{#sethostname}
setHostname
void setHostname(std::string_view hostname)
Defined in src/net/include/icy/net/ssladapter.h:79
Set the expected peer hostname for certificate verification. Must be called before initClient() to enable hostname verification.
{#addincomingdata}
addIncomingData
void addIncomingData(const char * data, size_t len)
Defined in src/net/include/icy/net/ssladapter.h:86
Feeds encrypted data received from the network into the SSL read BIO. Triggers a flush, which drives the handshake or decrypts and delivers plaintext to the socket via onRecv().
Parameters
-
dataPointer to the encrypted bytes. -
lenNumber of bytes to feed.
{#addoutgoingdata}
addOutgoingData
void addOutgoingData(std::string_view data)
Defined in src/net/include/icy/net/ssladapter.h:90
Queues plaintext data for encryption and transmission.
Parameters
dataString view of the plaintext payload.
{#addoutgoingdata-1}
addOutgoingData
void addOutgoingData(const char * data, size_t len)
Defined in src/net/include/icy/net/ssladapter.h:95
Queues plaintext data for encryption and transmission.
Parameters
-
dataPointer to the plaintext bytes. -
lenNumber of bytes to queue.
{#addoutgoingdata-2}
addOutgoingData
void addOutgoingData(Buffer && data)
Defined in src/net/include/icy/net/ssladapter.h:98
Moves plaintext data into the pending write buffer when possible.
Protected Attributes
| Return | Name | Description |
|---|---|---|
net::SSLSocket * | _socket | |
SSL * | _ssl | |
BIO * | _readBIO | The incoming buffer we write encrypted SSL data into. |
BIO * | _writeBIO | The outgoing buffer we write to the socket. |
std::vector< char > | _bufferOut | The outgoing payload to be encrypted and sent. |
std::string | _hostname | Expected peer hostname for verification. |
{#_socket}
_socket
net::SSLSocket * _socket
Defined in src/net/include/icy/net/ssladapter.h:109
{#_ssl}
_ssl
SSL * _ssl
Defined in src/net/include/icy/net/ssladapter.h:110
{#_readbio}
_readBIO
BIO * _readBIO
Defined in src/net/include/icy/net/ssladapter.h:111
The incoming buffer we write encrypted SSL data into.
{#_writebio}
_writeBIO
BIO * _writeBIO
Defined in src/net/include/icy/net/ssladapter.h:112
The outgoing buffer we write to the socket.
{#_bufferout}
_bufferOut
std::vector< char > _bufferOut
Defined in src/net/include/icy/net/ssladapter.h:113
The outgoing payload to be encrypted and sent.
{#_hostname}
_hostname
std::string _hostname
Defined in src/net/include/icy/net/ssladapter.h:114
Expected peer hostname for verification.
Protected Methods
| Return | Name | Description |
|---|---|---|
void | handleError | |
void | flushReadBIO | |
void | flushWriteBIO |
{#handleerror}
handleError
void handleError(int rc)
Defined in src/net/include/icy/net/ssladapter.h:101
{#flushreadbio}
flushReadBIO
void flushReadBIO()
Defined in src/net/include/icy/net/ssladapter.h:103
{#flushwritebio}
flushWriteBIO
void flushWriteBIO()
Defined in src/net/include/icy/net/ssladapter.h:104
{#sslcontext}
SSLContext
#include <icy/net/sslcontext.h>
class SSLContext
Defined in src/net/include/icy/net/sslcontext.h:44
OpenSSL SSL_CTX wrapper for client and server TLS configuration.
This class encapsulates context information for an SSL server or client, such as the certificate verification mode and the location of certificates and private key files, as well as the list of supported ciphers.
The Context class is also used to control SSL session caching on the server and client side.
List of all members
| Name | Kind | Owner |
|---|---|---|
SSLContext | function | Declared here |
SSLContext | function | Declared here |
~SSLContext | function | Declared here |
useCertificate | function | Declared here |
addChainCertificate | function | Declared here |
addVerificationCertificate | function | Declared here |
sslContext | function | Declared here |
usage | function | Declared here |
isForServerUse | function | Declared here |
verificationMode | function | Declared here |
enableSessionCache | function | Declared here |
enableSessionCache | function | Declared here |
sessionCacheEnabled | function | Declared here |
setSessionCacheSize | function | Declared here |
getSessionCacheSize | function | Declared here |
setSessionTimeout | function | Declared here |
getSessionTimeout | function | Declared here |
flushSessionCache | function | Declared here |
disableStatelessSessionResumption | function | Declared here |
setALPNProtocols | function | Declared here |
SSLContext | function | Declared here |
SSLContext | function | Declared here |
enableSNI | function | Declared here |
Usage | enum | Declared here |
VerificationMode | enum | Declared here |
Ptr | typedef | Declared here |
_usage | variable | Declared here |
_mode | variable | Declared here |
_sslContext | variable | Declared here |
_alpnWire | variable | Declared here |
createSSLContext | function | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
SSLContext | Creates a Context. | |
SSLContext | Creates a Context. | |
~SSLContext noexcept | Destroys the Context. | |
void | useCertificate | Sets the certificate to be used by the Context. |
void | addChainCertificate | Adds a certificate for certificate chain validation. |
void | addVerificationCertificate | Sets the private key to be used by the Context. |
SSL_CTX * | sslContext const inline | Returns the underlying OpenSSL SSL Context object. |
Usage | usage const inline | Returns whether the context is for use by a client or by a server and whether TLSv1 is required. |
bool | isForServerUse const inline | Returns true if the context is for use by a server. |
SSLContext::VerificationMode | verificationMode const inline | Returns the verification mode. |
void | enableSessionCache | Enable or disable SSL/TLS session caching. For session caching to work, it must be enabled on the server, as well as on the client side. |
void | enableSessionCache | Enables or disables SSL/TLS session caching on the server. For session caching to work, it must be enabled on the server, as well as on the client side. |
bool | sessionCacheEnabled const | Returns true if the session cache is enabled. |
void | setSessionCacheSize | Sets the maximum size of the server session cache, in number of sessions. The default size (according to OpenSSL documentation) is 1024*20, which may be too large for many applications, especially on embedded platforms with limited memory. |
size_t | getSessionCacheSize const | Returns the current maximum size of the server session cache. |
void | setSessionTimeout | Sets the timeout (in seconds) of cached sessions on the server. A cached session will be removed from the cache if it has not been used for the given number of seconds. |
long | getSessionTimeout const | Returns the timeout (in seconds) of cached sessions on the server. |
void | flushSessionCache | Flushes the SSL session cache on the server. |
void | disableStatelessSessionResumption | Newer versions of OpenSSL support RFC 4507 tickets for stateless session resumption. |
void | setALPNProtocols | Set the ALPN protocols for negotiation. Protocols should be in preference order. Example: {"h2", "http/1.1"} |
SSLContext | Deleted constructor. | |
SSLContext | Deleted constructor. |
{#sslcontext-1}
SSLContext
SSLContext(Usage usage, const std::string & privateKeyFile, const std::string & certificateFile, const std::string & caLocation, VerificationMode verificationMode = VERIFY_RELAXED, int verificationDepth = 9, bool loadDefaultCAs = false, const std::string & cipherList = "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH")
Defined in src/net/include/icy/net/sslcontext.h:123
Creates a Context.
-
usage specifies whether the context is used by a client or server.
-
privateKeyFile contains the path to the private key file used for encryption. Can be empty if no private key file is used.
-
certificateFile contains the path to the certificate file (in PEM format). If the private key and the certificate are stored in the same file, this can be empty if privateKeyFile is given.
-
caLocation contains the path to the file or directory containing the CA/root certificates. Can be empty if the OpenSSL builtin CA certificates are used (see loadDefaultCAs).
-
verificationMode specifies whether and how peer certificates are validated.
-
verificationDepth sets the upper limit for verification chain sizes. Verification will fail if a certificate chain larger than this is encountered.
-
loadDefaultCAs specifies whether the builtin CA certificates from OpenSSL are used.
-
cipherList specifies the supported ciphers in OpenSSL notation.
Note: If the private key is protected by a passphrase, a PrivateKeyPassphraseHandler must have been setup with the SSLManager, or the SSLManager's PrivateKeyPassphraseRequired event must be handled.
{#sslcontext-2}
SSLContext
SSLContext(Usage usage, const std::string & caLocation, VerificationMode verificationMode = VERIFY_RELAXED, int verificationDepth = 9, bool loadDefaultCAs = false, const std::string & cipherList = "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH")
Defined in src/net/include/icy/net/sslcontext.h:148
Creates a Context.
-
usage specifies whether the context is used by a client or server.
-
caLocation contains the path to the file or directory containing the CA/root certificates. Can be empty if the OpenSSL builtin CA certificates are used (see loadDefaultCAs).
-
verificationMode specifies whether and how peer certificates are validated.
-
verificationDepth sets the upper limit for verification chain sizes. Verification will fail if a certificate chain larger than this is encountered.
-
loadDefaultCAs specifies whether the builtin CA certificates from OpenSSL are used.
-
cipherList specifies the supported ciphers in OpenSSL notation.
Note that a private key and/or certificate must be specified with usePrivateKey()/useCertificate() before the Context can be used.
{#sslcontext-3}
~SSLContext
noexcept
~SSLContext() noexcept
Defined in src/net/include/icy/net/sslcontext.h:155
Destroys the Context.
{#usecertificate}
useCertificate
void useCertificate(crypto::X509Certificate & certificate)
Defined in src/net/include/icy/net/sslcontext.h:165
Sets the certificate to be used by the Context.
To set-up a complete certificate chain, it might be necessary to call addChainCertificate() to specify additional certificates.
Note that useCertificate() must always be called before usePrivateKey().
{#addchaincertificate}
addChainCertificate
void addChainCertificate(crypto::X509Certificate & certificate)
Defined in src/net/include/icy/net/sslcontext.h:168
Adds a certificate for certificate chain validation.
{#addverificationcertificate}
addVerificationCertificate
void addVerificationCertificate(crypto::X509Certificate & certificate)
Defined in src/net/include/icy/net/sslcontext.h:184
Sets the private key to be used by the Context.
Note that useCertificate() must always be called before usePrivateKey().
Note: If the private key is protected by a passphrase, a PrivateKeyPassphraseHandler must have been setup with the SSLManager, or the SSLManager's PrivateKeyPassphraseRequired event must be handled. Adds the given certificate to the list of trusted certificates that will be used for verification.
{#sslcontext-4}
sslContext
const inline
inline SSL_CTX * sslContext() const
Defined in src/net/include/icy/net/sslcontext.h:187
Returns the underlying OpenSSL SSL Context object.
{#usage}
usage
const inline
inline Usage usage() const
Defined in src/net/include/icy/net/sslcontext.h:191
Returns whether the context is for use by a client or by a server and whether TLSv1 is required.
{#isforserveruse}
isForServerUse
const inline
inline bool isForServerUse() const
Defined in src/net/include/icy/net/sslcontext.h:194
Returns true if the context is for use by a server.
{#verificationmode}
verificationMode
const inline
inline SSLContext::VerificationMode verificationMode() const
Defined in src/net/include/icy/net/sslcontext.h:197
Returns the verification mode.
{#enablesessioncache}
enableSessionCache
void enableSessionCache(bool flag = true)
Defined in src/net/include/icy/net/sslcontext.h:208
Enable or disable SSL/TLS session caching. For session caching to work, it must be enabled on the server, as well as on the client side.
The default is disabled session caching.
To enable session caching on the server side, use the two-argument version of this method to specify a session ID context.
{#enablesessioncache-1}
enableSessionCache
void enableSessionCache(bool flag, std::string_view sessionIdContext)
Defined in src/net/include/icy/net/sslcontext.h:225
Enables or disables SSL/TLS session caching on the server. For session caching to work, it must be enabled on the server, as well as on the client side.
SessionIdContext contains the application's unique session ID context, which becomes part of each session identifier generated by the server within this context. SessionIdContext can be an arbitrary sequence of bytes with a maximum length of SSL_MAX_SSL_SESSION_ID_LENGTH.
A non-empty sessionIdContext should be specified even if session caching is disabled to avoid problems with clients requesting to reuse a session (e.g. Firefox 3.6).
This method may only be called on SERVER_USE Context objects.
{#sessioncacheenabled}
sessionCacheEnabled
const
bool sessionCacheEnabled() const
Defined in src/net/include/icy/net/sslcontext.h:228
Returns true if the session cache is enabled.
{#setsessioncachesize}
setSessionCacheSize
void setSessionCacheSize(size_t size)
Defined in src/net/include/icy/net/sslcontext.h:238
Sets the maximum size of the server session cache, in number of sessions. The default size (according to OpenSSL documentation) is 1024*20, which may be too large for many applications, especially on embedded platforms with limited memory.
Specifying a size of 0 will set an unlimited cache size.
This method may only be called on SERVER_USE Context objects.
{#getsessioncachesize}
getSessionCacheSize
const
size_t getSessionCacheSize() const
Defined in src/net/include/icy/net/sslcontext.h:243
Returns the current maximum size of the server session cache.
This method may only be called on SERVER_USE Context objects.
{#setsessiontimeout}
setSessionTimeout
void setSessionTimeout(long seconds)
Defined in src/net/include/icy/net/sslcontext.h:250
Sets the timeout (in seconds) of cached sessions on the server. A cached session will be removed from the cache if it has not been used for the given number of seconds.
This method may only be called on SERVER_USE Context objects.
{#getsessiontimeout}
getSessionTimeout
const
long getSessionTimeout() const
Defined in src/net/include/icy/net/sslcontext.h:255
Returns the timeout (in seconds) of cached sessions on the server.
This method may only be called on SERVER_USE Context objects.
{#flushsessioncache}
flushSessionCache
void flushSessionCache()
Defined in src/net/include/icy/net/sslcontext.h:260
Flushes the SSL session cache on the server.
This method may only be called on SERVER_USE Context objects.
{#disablestatelesssessionresumption}
disableStatelessSessionResumption
void disableStatelessSessionResumption()
Defined in src/net/include/icy/net/sslcontext.h:266
Newer versions of OpenSSL support RFC 4507 tickets for stateless session resumption.
The feature can be disabled by calling this method.
{#setalpnprotocols}
setALPNProtocols
void setALPNProtocols(const std::vector< std::string > & protocols)
Defined in src/net/include/icy/net/sslcontext.h:271
Set the ALPN protocols for negotiation. Protocols should be in preference order. Example: {"h2", "http/1.1"}
{#sslcontext-5}
SSLContext
SSLContext(const SSLContext &) = delete
Defined in src/net/include/icy/net/sslcontext.h:278
Deleted constructor.
{#sslcontext-6}
SSLContext
SSLContext(SSLContext &&) = delete
Defined in src/net/include/icy/net/sslcontext.h:280
Deleted constructor.
Public Static Methods
| Return | Name | Description |
|---|---|---|
void | enableSNI static | Enable SNI (Server Name Indication) for a specific SSL connection. The hostname is sent during the TLS handshake to allow the server to select the appropriate certificate. |
{#enablesni}
enableSNI
static
static void enableSNI(SSL * ssl, const std::string & hostname)
Defined in src/net/include/icy/net/sslcontext.h:276
Enable SNI (Server Name Indication) for a specific SSL connection. The hostname is sent during the TLS handshake to allow the server to select the appropriate certificate.
Public Types
| Name | Description |
|---|---|
Usage | |
VerificationMode | |
Ptr |
{#usage-1}
Usage
enum Usage
Defined in src/net/include/icy/net/sslcontext.h:49
| Value | Description |
|---|---|
CLIENT_USE | Context is used by a client. |
SERVER_USE | Context is used by a server. |
TLSV1_CLIENT_USE | Context is used by a client requiring TLSv1. |
TLSV1_SERVER_USE | Context is used by a server requiring TLSv2. |
{#verificationmode-1}
VerificationMode
enum VerificationMode
Defined in src/net/include/icy/net/sslcontext.h:57
| Value | Description |
|---|---|
VERIFY_NONE | Server: The server will not send a client certificate request to the client, so the client will not send a certificate. |
VERIFY_RELAXED | Server: The server sends a client certificate request to the client. The certificate returned (if any) is checked. If the verification process fails, the TLS/SSL handshake is immediately terminated with an alert message containing the reason for the verification failure. |
VERIFY_STRICT | Server: If the client did not return a certificate, the TLS/SSL handshake is immediately terminated with a handshake failure alert. |
VERIFY_ONCE | Server: Only request a client certificate on the initial TLS/SSL handshake. Do not ask for a client certificate again in case of a renegotiation. |
{#ptr-6}
Ptr
using Ptr = std::shared_ptr< SSLContext >
Defined in src/net/include/icy/net/sslcontext.h:47
Private Attributes
| Return | Name | Description |
|---|---|---|
Usage | _usage | |
VerificationMode | _mode | |
SSL_CTX * | _sslContext | |
std::vector< unsigned char > | _alpnWire | Wire-format ALPN protocols for server selection. |
{#_usage}
_usage
Usage _usage
Defined in src/net/include/icy/net/sslcontext.h:287
{#_mode}
_mode
VerificationMode _mode
Defined in src/net/include/icy/net/sslcontext.h:288
{#_sslcontext}
_sslContext
SSL_CTX * _sslContext
Defined in src/net/include/icy/net/sslcontext.h:289
{#_alpnwire}
_alpnWire
std::vector< unsigned char > _alpnWire
Defined in src/net/include/icy/net/sslcontext.h:290
Wire-format ALPN protocols for server selection.
Private Methods
| Return | Name | Description |
|---|---|---|
void | createSSLContext | Create a SSL_CTX object according to Context configuration. |
{#createsslcontext}
createSSLContext
void createSSLContext()
Defined in src/net/include/icy/net/sslcontext.h:285
Create a SSL_CTX object according to Context configuration.
{#sslmanager}
SSLManager
#include <icy/net/sslmanager.h>
class SSLManager
Defined in src/net/include/icy/net/sslmanager.h:31
Singleton that owns the default client/server TLS contexts and related callbacks.
List of all members
| Name | Kind | Owner |
|---|---|---|
Singleton< SSLManager > | friend | Declared here |
SSLContext | friend | Declared here |
ServerVerificationError | variable | Declared here |
ClientVerificationError | variable | Declared here |
PrivateKeyPassphraseRequired | variable | Declared here |
initializeServer | function | Declared here |
initializeClient | function | Declared here |
defaultServerContext | function | Declared here |
defaultClientContext | function | Declared here |
shutdown | function | Declared here |
instance | function | Declared here |
destroy | function | Declared here |
initNoVerifyClient | function | Declared here |
initNoVerifyServer | function | Declared here |
_defaultServerContext | variable | Declared here |
_defaultClientContext | variable | Declared here |
_mutex | variable | Declared here |
SSLManager | function | Declared here |
~SSLManager | function | Declared here |
SSLManager | function | Declared here |
SSLManager | function | Declared here |
verifyCallback | function | Declared here |
Friends
| Name | Description |
|---|---|
Singleton< SSLManager > | |
SSLContext |
{#singletonsslmanager}
Singleton< SSLManager >
friend class Singleton< SSLManager >
Defined in src/net/include/icy/net/sslmanager.h:122
{#sslcontext-7}
SSLContext
friend class SSLContext
Defined in src/net/include/icy/net/sslmanager.h:125
Public Attributes
| Return | Name | Description |
|---|---|---|
ThreadSignal< void(VerificationErrorDetails &)> | ServerVerificationError | Fired whenever a certificate verification error is detected by the server during a handshake. |
ThreadSignal< void(VerificationErrorDetails &)> | ClientVerificationError | Fired whenever a certificate verification error is detected by the client during a handshake. |
ThreadSignal< void(std::string &)> | PrivateKeyPassphraseRequired | Fired when an encrypted certificate or private key is loaded. Not setting the password in the event parameter will result in a failure to load the certificate. |
{#serververificationerror}
ServerVerificationError
ThreadSignal< void(VerificationErrorDetails &)> ServerVerificationError
Defined in src/net/include/icy/net/sslmanager.h:49
Fired whenever a certificate verification error is detected by the server during a handshake.
{#clientverificationerror}
ClientVerificationError
ThreadSignal< void(VerificationErrorDetails &)> ClientVerificationError
Defined in src/net/include/icy/net/sslmanager.h:53
Fired whenever a certificate verification error is detected by the client during a handshake.
{#privatekeypassphraserequired}
PrivateKeyPassphraseRequired
ThreadSignal< void(std::string &)> PrivateKeyPassphraseRequired
Defined in src/net/include/icy/net/sslmanager.h:57
Fired when an encrypted certificate or private key is loaded. Not setting the password in the event parameter will result in a failure to load the certificate.
Public Methods
| Return | Name | Description |
|---|---|---|
void | initializeServer | Initializes the server side of the SSLManager server-side SSLContext. |
void | initializeClient | Initializes the client side of the SSLManager with a default client-side SSLContext. |
SSLContext::Ptr | defaultServerContext | Returns the default context used by the server if initialized. |
SSLContext::Ptr | defaultClientContext | Returns the default context used by the client if initialized. |
void | shutdown | Shuts down the SSLManager and releases the default context objects. After a call to shutdown(), the SSLManager can no longer be used. |
{#initializeserver}
initializeServer
void initializeServer(SSLContext::Ptr ptrContext)
Defined in src/net/include/icy/net/sslmanager.h:35
Initializes the server side of the SSLManager server-side SSLContext.
{#initializeclient}
initializeClient
void initializeClient(SSLContext::Ptr ptrContext)
Defined in src/net/include/icy/net/sslmanager.h:39
Initializes the client side of the SSLManager with a default client-side SSLContext.
{#defaultservercontext}
defaultServerContext
SSLContext::Ptr defaultServerContext()
Defined in src/net/include/icy/net/sslmanager.h:42
Returns the default context used by the server if initialized.
{#defaultclientcontext}
defaultClientContext
SSLContext::Ptr defaultClientContext()
Defined in src/net/include/icy/net/sslmanager.h:45
Returns the default context used by the client if initialized.
{#shutdown-3}
shutdown
void shutdown()
Defined in src/net/include/icy/net/sslmanager.h:66
Shuts down the SSLManager and releases the default context objects. After a call to shutdown(), the SSLManager can no longer be used.
Normally, it's not necessary to call this method directly, as this will be called either by uninitializeSSL(), or when the SSLManager instance is destroyed.
Public Static Methods
| Return | Name | Description |
|---|---|---|
SSLManager & | instance static | Returns the instance of the SSLManager singleton. |
void | destroy static | Shuts down and destroys the SSLManager singleton instance. |
void | initNoVerifyClient static | Initializes a default no-verify client context that's useful for testing. |
void | initNoVerifyServer static | Initializes a default no-verify server context that's useful for testing. Optionally accepts private key and certificate file paths for server identity; if omitted, no certificate is loaded. |
{#instance-2}
instance
static
static SSLManager & instance()
Defined in src/net/include/icy/net/sslmanager.h:69
Returns the instance of the SSLManager singleton.
{#destroy}
destroy
static
static void destroy()
Defined in src/net/include/icy/net/sslmanager.h:72
Shuts down and destroys the SSLManager singleton instance.
{#initnoverifyclient}
initNoVerifyClient
static
static void initNoVerifyClient()
Defined in src/net/include/icy/net/sslmanager.h:76
Initializes a default no-verify client context that's useful for testing.
{#initnoverifyserver}
initNoVerifyServer
static
static void initNoVerifyServer(const std::string & privateKeyFile = "", const std::string & certificateFile = "")
Defined in src/net/include/icy/net/sslmanager.h:81
Initializes a default no-verify server context that's useful for testing. Optionally accepts private key and certificate file paths for server identity; if omitted, no certificate is loaded.
Private Attributes
| Return | Name | Description |
|---|---|---|
SSLContext::Ptr | _defaultServerContext | |
SSLContext::Ptr | _defaultClientContext | |
std::mutex | _mutex |
{#_defaultservercontext}
_defaultServerContext
SSLContext::Ptr _defaultServerContext
Defined in src/net/include/icy/net/sslmanager.h:120
{#_defaultclientcontext}
_defaultClientContext
SSLContext::Ptr _defaultClientContext
Defined in src/net/include/icy/net/sslmanager.h:121
{#_mutex-6}
_mutex
std::mutex _mutex
Defined in src/net/include/icy/net/sslmanager.h:122
Private Methods
| Return | Name | Description |
|---|---|---|
SSLManager | Creates the SSLManager. | |
~SSLManager noexcept | Destroys the SSLManager. | |
SSLManager | Deleted constructor. | |
SSLManager | Deleted constructor. |
{#sslmanager-1}
SSLManager
SSLManager()
Defined in src/net/include/icy/net/sslmanager.h:105
Creates the SSLManager.
{#sslmanager-2}
~SSLManager
noexcept
~SSLManager() noexcept
Defined in src/net/include/icy/net/sslmanager.h:108
Destroys the SSLManager.
{#sslmanager-3}
SSLManager
SSLManager(const SSLManager &) = delete
Defined in src/net/include/icy/net/sslmanager.h:110
Deleted constructor.
{#sslmanager-4}
SSLManager
SSLManager(SSLManager &&) = delete
Defined in src/net/include/icy/net/sslmanager.h:112
Deleted constructor.
Private Static Methods
| Return | Name | Description |
|---|---|---|
int | verifyCallback static | The return value of this method defines how errors in verification are handled. Return 0 to terminate the handshake, or 1 to continue despite the error. |
{#verifycallback}
verifyCallback
static
static int verifyCallback(bool server, int ok, X509_STORE_CTX * pStore)
Defined in src/net/include/icy/net/sslmanager.h:118
The return value of this method defines how errors in verification are handled. Return 0 to terminate the handshake, or 1 to continue despite the error.
{#sslsession}
SSLSession
#include <icy/net/sslsession.h>
class SSLSession
Defined in src/net/include/icy/net/sslsession.h:31
Cached SSL/TLS session wrapper used for client-side resumption.
For session caching to work, a client must save the session object from an existing connection, if it wants to reuse it with a future connection.
List of all members
| Name | Kind | Owner |
|---|---|---|
sslSession | function | Declared here |
SSLSession | function | Declared here |
~SSLSession | function | Declared here |
SSLSession | function | Declared here |
SSLSession | function | Declared here |
SSLSession | function | Declared here |
_ptr | variable | Declared here |
Ptr | typedef | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
SSL_SESSION * | sslSession const | Returns the stored OpenSSL SSL_SESSION object. |
SSLSession | Creates a new SSLSession wrapping the given OpenSSL session object. | |
~SSLSession noexcept | Destroys the Session. | |
SSLSession | Constructs an empty SSLSession with a null session pointer. | |
SSLSession | Deleted constructor. | |
SSLSession | Deleted constructor. |
{#sslsession-1}
sslSession
const
SSL_SESSION * sslSession() const
Defined in src/net/include/icy/net/sslsession.h:37
Returns the stored OpenSSL SSL_SESSION object.
{#sslsession-2}
SSLSession
SSLSession(SSL_SESSION * ptr)
Defined in src/net/include/icy/net/sslsession.h:44
Creates a new SSLSession wrapping the given OpenSSL session object.
The SSL_SESSION's reference count is not incremented; the SSLSession takes ownership and will call SSL_SESSION_free() on destruction.
Parameters
ptrThe OpenSSL session object to wrap.
{#sslsession-3}
~SSLSession
noexcept
~SSLSession() noexcept
Defined in src/net/include/icy/net/sslsession.h:50
Destroys the Session.
Calls SSL_SESSION_free() on the stored SSL_SESSION object.
{#sslsession-4}
SSLSession
SSLSession()
Defined in src/net/include/icy/net/sslsession.h:53
Constructs an empty SSLSession with a null session pointer.
{#sslsession-5}
SSLSession
SSLSession(const SSLSession &) = delete
Defined in src/net/include/icy/net/sslsession.h:55
Deleted constructor.
{#sslsession-6}
SSLSession
SSLSession(SSLSession &&) = delete
Defined in src/net/include/icy/net/sslsession.h:57
Deleted constructor.
Protected Attributes
| Return | Name | Description |
|---|---|---|
SSL_SESSION * | _ptr |
{#_ptr}
_ptr
SSL_SESSION * _ptr
Defined in src/net/include/icy/net/sslsession.h:61
Public Types
| Name | Description |
|---|---|
Ptr |
{#ptr-7}
Ptr
using Ptr = std::shared_ptr< SSLSession >
Defined in src/net/include/icy/net/sslsession.h:34
{#sslsocket}
SSLSocket
#include <icy/net/sslsocket.h>
class SSLSocket
Defined in src/net/include/icy/net/sslsocket.h:30
Inherits:
TCPSocket
SSL socket implementation.
List of all members
| Name | Kind | Owner |
|---|---|---|
SSLAdapter | friend | Declared here |
SSLSocket | function | Declared here |
SSLSocket | function | Declared here |
SSLSocket | function | Declared here |
connect | function | Declared here |
connect | function | Declared here |
bind | function | Declared here |
listen | function | Declared here |
shutdown | function | Declared here |
close | function | Declared here |
send | function | Declared here |
sendOwned | function | Declared here |
send | function | Declared here |
sendOwned | function | Declared here |
setHostname | function | Declared here |
useContext | function | Declared here |
context | function | Declared here |
useSession | function | Declared here |
currentSession | function | Declared here |
sessionWasReused | function | Declared here |
available | function | Declared here |
peerCertificate | function | Declared here |
transport | function | Declared here |
acceptConnection | function | Declared here |
onConnect | function | Declared here |
onRead | function | Declared here |
_sslContext | variable | Declared here |
_sslSession | variable | Declared here |
_sslAdapter | variable | Declared here |
Ptr | typedef | Declared here |
Vec | typedef | Declared here |
AcceptConnection | variable | Inherited from TCPSocket |
TCPSocket | function | Inherited from TCPSocket |
TCPSocket | function | Inherited from TCPSocket |
TCPSocket | function | Inherited from TCPSocket |
shutdown | function | Inherited from TCPSocket |
close | function | Inherited from TCPSocket |
connect | function | Inherited from TCPSocket |
connect | function | Inherited from TCPSocket |
send | function | Inherited from TCPSocket |
sendOwned | function | Inherited from TCPSocket |
send | function | Inherited from TCPSocket |
sendOwned | function | Inherited from TCPSocket |
bind | function | Inherited from TCPSocket |
listen | function | Inherited from TCPSocket |
acceptConnection | function | Inherited from TCPSocket |
setReusePort | function | Inherited from TCPSocket |
setNoDelay | function | Inherited from TCPSocket |
setKeepAlive | function | Inherited from TCPSocket |
setSimultaneousAccepts | function | Inherited from TCPSocket |
setMode | function | Inherited from TCPSocket |
mode | function | Inherited from TCPSocket |
setError | function | Inherited from TCPSocket |
error | function | Inherited from TCPSocket |
closed | function | Inherited from TCPSocket |
address | function | Inherited from TCPSocket |
peerAddress | function | Inherited from TCPSocket |
transport | function | Inherited from TCPSocket |
loop | function | Inherited from TCPSocket |
onConnect | function | Inherited from TCPSocket |
onRead | function | Inherited from TCPSocket |
onRecv | function | Inherited from TCPSocket |
onError | function | Inherited from TCPSocket |
onClose | function | Inherited from TCPSocket |
_mode | variable | Inherited from TCPSocket |
_peerAddress | variable | Inherited from TCPSocket |
init | function | Inherited from TCPSocket |
reset | function | Inherited from TCPSocket |
Ptr | typedef | Inherited from TCPSocket |
Vec | typedef | Inherited from TCPSocket |
Handle | typedef | Inherited from Stream |
Read | variable | Inherited from Stream |
_buffer | variable | Inherited from Stream |
_started | variable | Inherited from Stream |
_highWaterMark | variable | Inherited from Stream |
_writeReqFree | variable | Inherited from Stream |
_ownedWriteReqFree | variable | Inherited from Stream |
Stream | function | Inherited from Stream |
~Stream | function | Inherited from Stream |
close | function | Inherited from Stream |
shutdown | function | Inherited from Stream |
write | function | Inherited from Stream |
writeOwned | function | Inherited from Stream |
setHighWaterMark | function | Inherited from Stream |
write | function | Inherited from Stream |
stream | function | Inherited from Stream |
readStart | function | Inherited from Stream |
readStop | function | Inherited from Stream |
onRead | function | Inherited from Stream |
allocWriteReq | function | Inherited from Stream |
freeWriteReq | function | Inherited from Stream |
allocOwnedWriteReq | function | Inherited from Stream |
freeOwnedWriteReq | function | Inherited from Stream |
canQueueWrite | function | Inherited from Stream |
handleRead | function | Inherited from Stream |
allocReadBuffer | function | Inherited from Stream |
Handle | function | Inherited from Handle |
init | function | Inherited from Handle |
invoke | function | Inherited from Handle |
invokeOrThrow | function | Inherited from Handle |
close | function | Inherited from Handle |
ref | function | Inherited from Handle |
unref | function | Inherited from Handle |
initialized | function | Inherited from Handle |
active | function | Inherited from Handle |
closing | function | Inherited from Handle |
closed | function | Inherited from Handle |
error | function | Inherited from Handle |
setError | function | Inherited from Handle |
setUVError | function | Inherited from Handle |
setAndThrowError | function | Inherited from Handle |
throwLastError | function | Inherited from Handle |
loop | function | Inherited from Handle |
reset | function | Inherited from Handle |
get | function | Inherited from Handle |
tid | function | Inherited from Handle |
context | function | Inherited from Handle |
setCloseCleanup | function | Inherited from Handle |
clearCloseCleanup | function | Inherited from Handle |
assertThread | function | Inherited from Handle |
_loop | variable | Inherited from Handle |
_context | variable | Inherited from Handle |
_tid | variable | Inherited from Handle |
_error | variable | Inherited from Handle |
onError | function | Inherited from Handle |
onClose | function | Inherited from Handle |
Handle | function | Inherited from Handle |
Handle | function | Inherited from Handle |
Type | typedef | Inherited from Handle |
opaque | variable | Inherited from Socket |
Socket | function | Inherited from Socket |
Socket | function | Inherited from Socket |
Socket | function | Inherited from Socket |
connect | function | Inherited from Socket |
connect | function | Inherited from Socket |
bind | function | Inherited from Socket |
listen | function | Inherited from Socket |
shutdown | function | Inherited from Socket |
sendOwned | function | Inherited from Socket |
sendOwned | function | Inherited from Socket |
close | function | Inherited from Socket |
address | function | Inherited from Socket |
peerAddress | function | Inherited from Socket |
transport | function | Inherited from Socket |
setError | function | Inherited from Socket |
error | function | Inherited from Socket |
closed | function | Inherited from Socket |
loop | function | Inherited from Socket |
_af | variable | Inherited from Socket |
init | function | Inherited from Socket |
reset | function | Inherited from Socket |
Ptr | typedef | Inherited from Socket |
Vec | typedef | Inherited from Socket |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from TCPSocket
| Kind | Name | Description |
|---|---|---|
variable | AcceptConnection | Fired when a new client connection is accepted; carries a shared_ptr to the new socket. |
function | TCPSocket | Constructs the TCPSocket and initializes the underlying libuv handle. |
function | TCPSocket | Deleted constructor. |
function | TCPSocket | Deleted constructor. |
function | shutdown virtual nodiscard override | Sends a TCP shutdown request; the socket closes after the peer acknowledges. |
function | close virtual override | Closes the socket immediately, releasing all associated resources. |
function | connect virtual override | Connects to peerAddress using a libuv connect request. On success, calls onConnect(); on failure, calls setUVError(). |
function | connect virtual override | Resolves host via DNS (or maps "localhost"), then connects. |
function | send virtual nodiscard override | Writes len bytes to the connected peer. |
function | sendOwned virtual nodiscard override | Sends an owned payload buffer to the connected peer. |
function | send virtual nodiscard override | Writes len bytes; peerAddress is ignored for TCP (connected stream). |
function | sendOwned virtual nodiscard override | |
function | bind virtual override | Binds the socket to address. Resets and reinitializes the handle if the address family changes. |
function | listen virtual override | Starts listening for incoming connections with the given backlog. |
function | acceptConnection virtual | Accepts the next pending client connection and fires AcceptConnection. |
function | setReusePort nodiscard | Enables SO_REUSEPORT on Linux kernel >= 3.9 for multi-thread load balancing. Must be called after bind(). No-op and returns false on unsupported platforms. |
function | setNoDelay nodiscard | Enables or disables TCP_NODELAY (Nagle's algorithm). |
function | setKeepAlive nodiscard | Enables or disables TCP keep-alive probes. |
function | setSimultaneousAccepts nodiscard | Enables or disables simultaneous accepts on Windows. No-op and returns false on non-Windows platforms. |
function | setMode | Sets the socket mode (ServerSide or ClientSide). |
function | mode const | Returns the current socket mode. |
function | setError virtual override | Sets the socket error; ignores the call if an error is already recorded. Setting an error causes the socket to close. |
function | error virtual const override | Returns the current socket error, if any. |
function | closed virtual const override | Returns true if the native socket handle is closed. |
function | address virtual const override | Returns the IP address and port number of the socket. A wildcard address is returned if the socket is not connected. |
function | peerAddress virtual const override | Returns the IP address and port number of the peer socket. A wildcard address is returned if the socket is not connected. |
function | transport virtual const override | Returns the TCP transport protocol. |
function | loop virtual const override | Returns the event loop associated with this socket. |
function | onConnect virtual | Called by the stream layer when the TCP connection is established. |
function | onRead virtual override | Called by the stream layer with raw received bytes; wraps them in a MutableBuffer. |
function | onRecv virtual | Dispatches a received buffer to all socket adapters via onSocketRecv. |
function | onError virtual override | Dispatches the error to adapters and closes the socket. |
function | onClose virtual override | Dispatches the close event to all socket adapters. |
variable | _mode | |
variable | _peerAddress | Cached peer address (avoids syscall per recv). |
function | init virtual override | Initializes the underlying socket context. |
function | reset virtual override | Resets the socket context for reuse. |
typedef | Ptr | |
typedef | Vec |
Inherited from Stream
| Kind | Name | Description |
|---|---|---|
typedef | Handle | |
variable | Read | Emitted when data has been received from the peer. |
variable | _buffer | |
variable | _started | |
variable | _highWaterMark | 16MB default write queue limit |
variable | _writeReqFree | Freelist for write requests. |
variable | _ownedWriteReqFree | Freelist for owned write requests. |
function | Stream inline | Construct the stream bound to loop with a 64 KiB read buffer. |
function | ~Stream virtual inline | Destroy the stream, stopping reads and freeing pooled write requests. |
function | close virtual inline override | Closes and resets the stream handle. This will close the active socket/pipe and destroy the handle. |
function | shutdown inline | Send a TCP/pipe shutdown request to the connected peer. |
function | write inline | Write len bytes from data to the stream. |
function | writeOwned inline | Write an owned payload buffer to the stream. |
function | setHighWaterMark inline | Set the high water mark for the write queue (default 16MB). When the write queue exceeds this size, write() returns false. |
function | write inline | Write len bytes from data together with a stream handle over an IPC pipe (uses uv_write2). |
function | stream inline | Return the underlying uv_stream_t pointer cast from the native handle. |
function | readStart virtual inline | Begin reading from the stream by registering libuv read callbacks. |
function | readStop virtual inline | Stop reading from the stream. |
function | onRead virtual inline | Called by [handleRead](base.md#classicy_1_1Stream_1ac74fea672c0d281f2a4f51bee6943b10) when len bytes of data arrive. |
function | allocWriteReq inline | Return a uv_write_t from the freelist, or allocate a new one if the pool is empty. |
function | freeWriteReq inline | Return req to the freelist, or delete it if the pool is at capacity. |
function | allocOwnedWriteReq inline | |
function | freeOwnedWriteReq inline | |
function | canQueueWrite inline | |
function | handleRead static inline | UV callbacks. |
function | allocReadBuffer static inline | libuv allocate-buffer callback. Provides the stream's internal buffer, growing it if libuv requests more space than the current allocation. |
Inherited from Handle
| Kind | Name | Description |
|---|---|---|
function | Handle inline | Construct the handle bound to the given event loop. |
function | init inline | Initialize the underlying libuv handle by calling f with the loop, the raw handle pointer, and any additional args. |
function | invoke inline | Invoke a libuv function f with args on the initialized handle. |
function | invokeOrThrow inline | Invoke a libuv function f with args, throwing on failure. |
function | close virtual inline | Close and destroy the handle. |
function | ref inline | Re-reference the handle with the event loop after a previous [unref()](uv.md#unref). |
function | unref inline | Unreference the handle from the event loop. |
function | initialized const inline | Return true if the handle has been successfully initialized via [init()](uv.md#init-2). |
function | active virtual const inline | Return true when the handle is active (libuv uv_is_active). |
function | closing virtual const inline | Return true if uv_close has been called and the handle is awaiting its close callback (libuv uv_is_closing). |
function | closed virtual const inline | Return true if the handle has been fully closed (context released). |
function | error const inline | Return the last error set on this handle, or a default-constructed [Error](base.md#error) if no error has occurred. |
function | setError virtual inline | Set the error state and invoke [onError()](uv.md#onerror). |
function | setUVError inline | Translate a libuv error code into an [Error](base.md#error) and call [setError()](uv.md#seterror). |
function | setAndThrowError inline | Set the error state from a libuv error code and throw a std::runtime_error. |
function | throwLastError inline | Throw a std::runtime_error if the handle currently holds an error. |
function | loop const inline | Return the event loop this handle is bound to. |
function | reset inline | Close the current handle (if open) and allocate a fresh [Context](uv.md#context-1), leaving the handle ready to be re-initialized via [init()](uv.md#init-2). |
function | get const inline | Return the raw libuv handle pointer cast to [Handle](uv.md#handle-2). |
function | tid const inline | Return the ID of the thread that constructed this handle. |
function | context const inline | Return the raw [Context](uv.md#context-1) that owns the libuv handle memory. |
function | setCloseCleanup inline | |
function | clearCloseCleanup inline | |
function | assertThread const inline | Throw std::logic_error if called from any thread other than the thread that constructed this handle. |
variable | _loop | |
variable | _context | |
variable | _tid | |
variable | _error | |
function | onError virtual inline | Called by [setError()](uv.md#seterror) after the error state has been updated. |
function | onClose virtual inline | Called by [close()](uv.md#close-11) after the context has been released. |
function | Handle | NonCopyable and NonMovable. |
function | Handle | Deleted constructor. |
typedef | Type | Define the native handle type. |
Inherited from Socket
| Kind | Name | Description |
|---|---|---|
variable | opaque | Optional client data. |
function | Socket | Defaulted constructor. |
function | Socket | Deleted constructor. |
function | Socket | Deleted constructor. |
function | connect virtual | Connects to the given peer IP address. |
function | connect virtual | Resolves and connects to the given host address. |
function | bind virtual | Bind a local address to the socket. The address may be IPv4 or IPv6 (if supported). |
function | listen virtual inline | Listens the socket on the given address. |
function | shutdown virtual inline nodiscard | Sends the shutdown packet which should result is socket closure via callback. |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | close virtual | Closes the underlying socket. |
function | address virtual const | The locally bound address. |
function | peerAddress virtual const | The connected peer address. |
function | transport virtual const | The transport protocol: TCP, UDP or SSLTCP. |
function | setError virtual | Sets the socket error. |
function | error virtual const | Return the socket error if any. |
function | closed virtual const | Returns true if the native socket handle is closed. |
function | loop virtual const | Returns the socket event loop. |
variable | _af | |
function | init virtual | Initializes the underlying socket context. |
function | reset virtual | Resets the socket context for reuse. |
typedef | Ptr | |
typedef | Vec |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Friends
| Name | Description |
|---|---|
net::SSLAdapter |
{#net-ssladapter}
net::SSLAdapter
friend class net::SSLAdapter
Defined in src/net/include/icy/net/sslsocket.h:169
Public Methods
| Return | Name | Description |
|---|---|---|
SSLSocket | Constructs an SSLSocket that acquires its context from SSLManager on first use. | |
SSLSocket | Constructs an SSLSocket with an explicit SSL context. | |
SSLSocket | Constructs an SSLSocket with an explicit context and a prior session for resumption. | |
void | connect virtual override | Initialize the SSLSocket with the given SSLContext. |
void | connect virtual override | Resolves host and initiates a secure connection. |
void | bind virtual override | Binds the socket to address for server-side use. Throws std::logic_error if the context is not a server context. |
void | listen virtual override | Starts listening for incoming connections. Throws std::logic_error if the context is not a server context. |
bool | shutdown virtual nodiscard override | Shuts down the connection by attempting an orderly SSL shutdown, then actually shutting down the TCP connection. |
void | close virtual override | Closes the socket forcefully. |
ssize_t | send virtual nodiscard override | Encrypts and sends len bytes to the connected peer. |
ssize_t | sendOwned virtual nodiscard override | Sends an owned payload buffer to the connected peer. |
ssize_t | send virtual nodiscard override | Encrypts and sends len bytes, ignoring peerAddress (TCP is connected). |
ssize_t | sendOwned virtual nodiscard override | |
void | setHostname | Set the expected peer hostname for certificate verification and SNI. Must be called before connect() to enable hostname verification. |
void | useContext | Use the given SSL context for this socket. |
SSLContext::Ptr | context const | Returns the SSL context used for this socket. |
void | useSession | Sets the SSL session to use for the next connection. Setting a previously saved Session object is necessary to enable session caching. |
SSLSession::Ptr | currentSession | Returns the SSL session of the current connection, for reuse in a future connection (if session caching is enabled). |
bool | sessionWasReused | Returns true if a reused session was negotiated during the handshake. |
int | available const | Returns the number of bytes available from the SSL buffer for immediate reading. |
X509 * | peerCertificate const | Returns the peer's X.509 certificate, or nullptr if no certificate was presented. |
net::TransportType | transport virtual const override | Returns the SSLTCP transport protocol identifier. |
void | acceptConnection virtual override | Accepts a pending client connection, initializes the server-side SSL context on the new socket, and fires the AcceptConnection signal. |
void | onConnect virtual override | Called when the TCP connection is established; starts reading and initiates the client-side SSL handshake. |
void | onRead virtual override | Feeds raw encrypted bytes from the network into the SSL adapter. Called by the stream layer when ciphertext arrives from the peer. |
{#sslsocket-1}
SSLSocket
SSLSocket(uv::Loop * loop = uv::defaultLoop())
Defined in src/net/include/icy/net/sslsocket.h:38
Constructs an SSLSocket that acquires its context from SSLManager on first use.
Parameters
loopEvent loop to use; defaults to the default loop.
{#sslsocket-2}
SSLSocket
SSLSocket(SSLContext::Ptr sslContext, uv::Loop * loop = uv::defaultLoop())
Defined in src/net/include/icy/net/sslsocket.h:43
Constructs an SSLSocket with an explicit SSL context.
Parameters
-
sslContextThe SSL context to use for this connection. -
loopEvent loop to use; defaults to the default loop.
{#sslsocket-3}
SSLSocket
SSLSocket(SSLContext::Ptr sslContext, SSLSession::Ptr session, uv::Loop * loop = uv::defaultLoop())
Defined in src/net/include/icy/net/sslsocket.h:49
Constructs an SSLSocket with an explicit context and a prior session for resumption.
Parameters
-
sslContextThe SSL context to use for this connection. -
sessionA previously saved session to attempt resumption with. -
loopEvent loop to use; defaults to the default loop.
{#connect-5}
connect
virtual override
virtual void connect(const Address & peerAddress) override
Defined in src/net/include/icy/net/sslsocket.h:61
Initialize the SSLSocket with the given SSLContext.
Initiates a secure connection to the peer at the given address.
The SSL handshake begins automatically once the TCP connection is established.
Parameters
peerAddressThe remote address to connect to.
Reimplements
{#connect-6}
connect
virtual override
virtual void connect(std::string_view host, uint16_t port) override
Defined in src/net/include/icy/net/sslsocket.h:69
Resolves host and initiates a secure connection.
Sets the hostname on the SSL adapter for SNI and certificate verification before resolving and connecting.
Parameters
-
hostHostname or IP address string. -
portDestination port.
Reimplements
{#bind-1}
bind
virtual override
virtual void bind(const net::Address & address, unsigned flags = 0) override
Defined in src/net/include/icy/net/sslsocket.h:75
Binds the socket to address for server-side use. Throws std::logic_error if the context is not a server context.
Parameters
-
addressLocal address to bind to. -
flagsOptional bind flags (passed to uv_tcp_bind).
Reimplements
{#listen-1}
listen
virtual override
virtual void listen(int backlog = 64) override
Defined in src/net/include/icy/net/sslsocket.h:80
Starts listening for incoming connections. Throws std::logic_error if the context is not a server context.
Parameters
backlogMaximum number of pending connections.
Reimplements
{#shutdown-4}
shutdown
virtual nodiscard override
[[nodiscard]] virtual bool shutdown() override
Defined in src/net/include/icy/net/sslsocket.h:85
Shuts down the connection by attempting an orderly SSL shutdown, then actually shutting down the TCP connection.
Reimplements
{#close-14}
close
virtual override
virtual void close() override
Defined in src/net/include/icy/net/sslsocket.h:88
Closes the socket forcefully.
Reimplements
{#send-2}
send
virtual nodiscard override
[[nodiscard]] virtual ssize_t send(const char * data, size_t len, int flags = 0) override
Defined in src/net/include/icy/net/sslsocket.h:95
Encrypts and sends len bytes to the connected peer.
Parameters
-
dataPointer to the plaintext payload. -
lenNumber of bytes to send. -
flagsReserved; currently unused.
Returns
Number of plaintext bytes accepted, or -1 on error.
Reimplements
{#sendowned-4}
sendOwned
virtual nodiscard override
[[nodiscard]] virtual ssize_t sendOwned(Buffer && buffer, int flags = 0) override
Defined in src/net/include/icy/net/sslsocket.h:96
Sends an owned payload buffer to the connected peer.
Reimplements
{#send-3}
send
virtual nodiscard override
[[nodiscard]] virtual ssize_t send(const char * data, size_t len, const net::Address & peerAddress, int flags = 0) override
Defined in src/net/include/icy/net/sslsocket.h:104
Encrypts and sends len bytes, ignoring peerAddress (TCP is connected).
Parameters
-
dataPointer to the plaintext payload. -
lenNumber of bytes to send. -
peerAddressIgnored for SSL/TCP; present for interface conformance. -
flagsReserved; currently unused.
Returns
Number of plaintext bytes accepted, or -1 on error.
Reimplements
{#sendowned-5}
sendOwned
virtual nodiscard override
[[nodiscard]] virtual ssize_t sendOwned(Buffer && buffer, const net::Address & peerAddress, int flags = 0) override
Defined in src/net/include/icy/net/sslsocket.h:106
Reimplements
{#sethostname-1}
setHostname
void setHostname(std::string_view hostname)
Defined in src/net/include/icy/net/sslsocket.h:111
Set the expected peer hostname for certificate verification and SNI. Must be called before connect() to enable hostname verification.
{#usecontext}
useContext
void useContext(SSLContext::Ptr context)
Defined in src/net/include/icy/net/sslsocket.h:114
Use the given SSL context for this socket.
{#context-4}
context
const
SSLContext::Ptr context() const
Defined in src/net/include/icy/net/sslsocket.h:117
Returns the SSL context used for this socket.
{#usesession}
useSession
void useSession(SSLSession::Ptr session)
Defined in src/net/include/icy/net/sslsocket.h:127
Sets the SSL session to use for the next connection. Setting a previously saved Session object is necessary to enable session caching.
To remove the currently set session, a nullptr pointer can be given.
Must be called before connect() to be effective.
{#currentsession}
currentSession
SSLSession::Ptr currentSession()
Defined in src/net/include/icy/net/sslsocket.h:134
Returns the SSL session of the current connection, for reuse in a future connection (if session caching is enabled).
If no connection is established, returns nullptr.
{#sessionwasreused}
sessionWasReused
bool sessionWasReused()
Defined in src/net/include/icy/net/sslsocket.h:138
Returns true if a reused session was negotiated during the handshake.
{#available-2}
available
const
int available() const
Defined in src/net/include/icy/net/sslsocket.h:142
Returns the number of bytes available from the SSL buffer for immediate reading.
{#peercertificate}
peerCertificate
const
X509 * peerCertificate() const
Defined in src/net/include/icy/net/sslsocket.h:145
Returns the peer's X.509 certificate, or nullptr if no certificate was presented.
{#transport-1}
transport
virtual const override
virtual net::TransportType transport() const override
Defined in src/net/include/icy/net/sslsocket.h:148
Returns the SSLTCP transport protocol identifier.
Reimplements
{#acceptconnection}
acceptConnection
virtual override
virtual void acceptConnection() override
Defined in src/net/include/icy/net/sslsocket.h:152
Accepts a pending client connection, initializes the server-side SSL context on the new socket, and fires the AcceptConnection signal.
Reimplements
{#onconnect}
onConnect
virtual override
virtual void onConnect() override
Defined in src/net/include/icy/net/sslsocket.h:156
Called when the TCP connection is established; starts reading and initiates the client-side SSL handshake.
Reimplements
{#onread}
onRead
virtual override
virtual void onRead(const char * data, size_t len) override
Defined in src/net/include/icy/net/sslsocket.h:162
Feeds raw encrypted bytes from the network into the SSL adapter. Called by the stream layer when ciphertext arrives from the peer.
Parameters
-
dataPointer to the encrypted bytes. -
lenNumber of bytes received.
Reimplements
Protected Attributes
| Return | Name | Description |
|---|---|---|
net::SSLContext::Ptr | _sslContext | |
net::SSLSession::Ptr | _sslSession | |
net::SSLAdapter | _sslAdapter |
{#_sslcontext-1}
_sslContext
net::SSLContext::Ptr _sslContext
Defined in src/net/include/icy/net/sslsocket.h:165
{#_sslsession}
_sslSession
net::SSLSession::Ptr _sslSession
Defined in src/net/include/icy/net/sslsocket.h:166
{#_ssladapter}
_sslAdapter
net::SSLAdapter _sslAdapter
Defined in src/net/include/icy/net/sslsocket.h:167
Public Types
| Name | Description |
|---|---|
Ptr | |
Vec |
{#ptr-8}
Ptr
using Ptr = std::shared_ptr< SSLSocket >
Defined in src/net/include/icy/net/sslsocket.h:33
{#vec-1}
Vec
using Vec = std::vector< Ptr >
Defined in src/net/include/icy/net/sslsocket.h:34
{#tcpsocket}
TCPSocket
#include <icy/net/tcpsocket.h>
class TCPSocket
Defined in src/net/include/icy/net/tcpsocket.h:30
Inherits:
Stream< uv_tcp_t >,SocketSubclassed by:SSLSocket
TCP socket implementation.
List of all members
| Name | Kind | Owner |
|---|---|---|
AcceptConnection | variable | Declared here |
TCPSocket | function | Declared here |
TCPSocket | function | Declared here |
TCPSocket | function | Declared here |
shutdown | function | Declared here |
close | function | Declared here |
connect | function | Declared here |
connect | function | Declared here |
send | function | Declared here |
sendOwned | function | Declared here |
send | function | Declared here |
sendOwned | function | Declared here |
bind | function | Declared here |
listen | function | Declared here |
acceptConnection | function | Declared here |
setReusePort | function | Declared here |
setNoDelay | function | Declared here |
setKeepAlive | function | Declared here |
setSimultaneousAccepts | function | Declared here |
setMode | function | Declared here |
mode | function | Declared here |
setError | function | Declared here |
error | function | Declared here |
closed | function | Declared here |
address | function | Declared here |
peerAddress | function | Declared here |
transport | function | Declared here |
loop | function | Declared here |
onConnect | function | Declared here |
onRead | function | Declared here |
onRecv | function | Declared here |
onError | function | Declared here |
onClose | function | Declared here |
_mode | variable | Declared here |
_peerAddress | variable | Declared here |
init | function | Declared here |
reset | function | Declared here |
Ptr | typedef | Declared here |
Vec | typedef | Declared here |
Handle | typedef | Inherited from Stream |
Read | variable | Inherited from Stream |
_buffer | variable | Inherited from Stream |
_started | variable | Inherited from Stream |
_highWaterMark | variable | Inherited from Stream |
_writeReqFree | variable | Inherited from Stream |
_ownedWriteReqFree | variable | Inherited from Stream |
Stream | function | Inherited from Stream |
~Stream | function | Inherited from Stream |
close | function | Inherited from Stream |
shutdown | function | Inherited from Stream |
write | function | Inherited from Stream |
writeOwned | function | Inherited from Stream |
setHighWaterMark | function | Inherited from Stream |
write | function | Inherited from Stream |
stream | function | Inherited from Stream |
readStart | function | Inherited from Stream |
readStop | function | Inherited from Stream |
onRead | function | Inherited from Stream |
allocWriteReq | function | Inherited from Stream |
freeWriteReq | function | Inherited from Stream |
allocOwnedWriteReq | function | Inherited from Stream |
freeOwnedWriteReq | function | Inherited from Stream |
canQueueWrite | function | Inherited from Stream |
handleRead | function | Inherited from Stream |
allocReadBuffer | function | Inherited from Stream |
Handle | function | Inherited from Handle |
init | function | Inherited from Handle |
invoke | function | Inherited from Handle |
invokeOrThrow | function | Inherited from Handle |
close | function | Inherited from Handle |
ref | function | Inherited from Handle |
unref | function | Inherited from Handle |
initialized | function | Inherited from Handle |
active | function | Inherited from Handle |
closing | function | Inherited from Handle |
closed | function | Inherited from Handle |
error | function | Inherited from Handle |
setError | function | Inherited from Handle |
setUVError | function | Inherited from Handle |
setAndThrowError | function | Inherited from Handle |
throwLastError | function | Inherited from Handle |
loop | function | Inherited from Handle |
reset | function | Inherited from Handle |
get | function | Inherited from Handle |
tid | function | Inherited from Handle |
context | function | Inherited from Handle |
setCloseCleanup | function | Inherited from Handle |
clearCloseCleanup | function | Inherited from Handle |
assertThread | function | Inherited from Handle |
_loop | variable | Inherited from Handle |
_context | variable | Inherited from Handle |
_tid | variable | Inherited from Handle |
_error | variable | Inherited from Handle |
onError | function | Inherited from Handle |
onClose | function | Inherited from Handle |
Handle | function | Inherited from Handle |
Handle | function | Inherited from Handle |
Type | typedef | Inherited from Handle |
opaque | variable | Inherited from Socket |
Socket | function | Inherited from Socket |
Socket | function | Inherited from Socket |
Socket | function | Inherited from Socket |
connect | function | Inherited from Socket |
connect | function | Inherited from Socket |
bind | function | Inherited from Socket |
listen | function | Inherited from Socket |
shutdown | function | Inherited from Socket |
sendOwned | function | Inherited from Socket |
sendOwned | function | Inherited from Socket |
close | function | Inherited from Socket |
address | function | Inherited from Socket |
peerAddress | function | Inherited from Socket |
transport | function | Inherited from Socket |
setError | function | Inherited from Socket |
error | function | Inherited from Socket |
closed | function | Inherited from Socket |
loop | function | Inherited from Socket |
_af | variable | Inherited from Socket |
init | function | Inherited from Socket |
reset | function | Inherited from Socket |
Ptr | typedef | Inherited from Socket |
Vec | typedef | Inherited from Socket |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from Stream
| Kind | Name | Description |
|---|---|---|
typedef | Handle | |
variable | Read | Emitted when data has been received from the peer. |
variable | _buffer | |
variable | _started | |
variable | _highWaterMark | 16MB default write queue limit |
variable | _writeReqFree | Freelist for write requests. |
variable | _ownedWriteReqFree | Freelist for owned write requests. |
function | Stream inline | Construct the stream bound to loop with a 64 KiB read buffer. |
function | ~Stream virtual inline | Destroy the stream, stopping reads and freeing pooled write requests. |
function | close virtual inline override | Closes and resets the stream handle. This will close the active socket/pipe and destroy the handle. |
function | shutdown inline | Send a TCP/pipe shutdown request to the connected peer. |
function | write inline | Write len bytes from data to the stream. |
function | writeOwned inline | Write an owned payload buffer to the stream. |
function | setHighWaterMark inline | Set the high water mark for the write queue (default 16MB). When the write queue exceeds this size, write() returns false. |
function | write inline | Write len bytes from data together with a stream handle over an IPC pipe (uses uv_write2). |
function | stream inline | Return the underlying uv_stream_t pointer cast from the native handle. |
function | readStart virtual inline | Begin reading from the stream by registering libuv read callbacks. |
function | readStop virtual inline | Stop reading from the stream. |
function | onRead virtual inline | Called by [handleRead](base.md#classicy_1_1Stream_1ac74fea672c0d281f2a4f51bee6943b10) when len bytes of data arrive. |
function | allocWriteReq inline | Return a uv_write_t from the freelist, or allocate a new one if the pool is empty. |
function | freeWriteReq inline | Return req to the freelist, or delete it if the pool is at capacity. |
function | allocOwnedWriteReq inline | |
function | freeOwnedWriteReq inline | |
function | canQueueWrite inline | |
function | handleRead static inline | UV callbacks. |
function | allocReadBuffer static inline | libuv allocate-buffer callback. Provides the stream's internal buffer, growing it if libuv requests more space than the current allocation. |
Inherited from Handle
| Kind | Name | Description |
|---|---|---|
function | Handle inline | Construct the handle bound to the given event loop. |
function | init inline | Initialize the underlying libuv handle by calling f with the loop, the raw handle pointer, and any additional args. |
function | invoke inline | Invoke a libuv function f with args on the initialized handle. |
function | invokeOrThrow inline | Invoke a libuv function f with args, throwing on failure. |
function | close virtual inline | Close and destroy the handle. |
function | ref inline | Re-reference the handle with the event loop after a previous [unref()](uv.md#unref). |
function | unref inline | Unreference the handle from the event loop. |
function | initialized const inline | Return true if the handle has been successfully initialized via [init()](uv.md#init-2). |
function | active virtual const inline | Return true when the handle is active (libuv uv_is_active). |
function | closing virtual const inline | Return true if uv_close has been called and the handle is awaiting its close callback (libuv uv_is_closing). |
function | closed virtual const inline | Return true if the handle has been fully closed (context released). |
function | error const inline | Return the last error set on this handle, or a default-constructed [Error](base.md#error) if no error has occurred. |
function | setError virtual inline | Set the error state and invoke [onError()](uv.md#onerror). |
function | setUVError inline | Translate a libuv error code into an [Error](base.md#error) and call [setError()](uv.md#seterror). |
function | setAndThrowError inline | Set the error state from a libuv error code and throw a std::runtime_error. |
function | throwLastError inline | Throw a std::runtime_error if the handle currently holds an error. |
function | loop const inline | Return the event loop this handle is bound to. |
function | reset inline | Close the current handle (if open) and allocate a fresh [Context](uv.md#context-1), leaving the handle ready to be re-initialized via [init()](uv.md#init-2). |
function | get const inline | Return the raw libuv handle pointer cast to [Handle](uv.md#handle-2). |
function | tid const inline | Return the ID of the thread that constructed this handle. |
function | context const inline | Return the raw [Context](uv.md#context-1) that owns the libuv handle memory. |
function | setCloseCleanup inline | |
function | clearCloseCleanup inline | |
function | assertThread const inline | Throw std::logic_error if called from any thread other than the thread that constructed this handle. |
variable | _loop | |
variable | _context | |
variable | _tid | |
variable | _error | |
function | onError virtual inline | Called by [setError()](uv.md#seterror) after the error state has been updated. |
function | onClose virtual inline | Called by [close()](uv.md#close-11) after the context has been released. |
function | Handle | NonCopyable and NonMovable. |
function | Handle | Deleted constructor. |
typedef | Type | Define the native handle type. |
Inherited from Socket
| Kind | Name | Description |
|---|---|---|
variable | opaque | Optional client data. |
function | Socket | Defaulted constructor. |
function | Socket | Deleted constructor. |
function | Socket | Deleted constructor. |
function | connect virtual | Connects to the given peer IP address. |
function | connect virtual | Resolves and connects to the given host address. |
function | bind virtual | Bind a local address to the socket. The address may be IPv4 or IPv6 (if supported). |
function | listen virtual inline | Listens the socket on the given address. |
function | shutdown virtual inline nodiscard | Sends the shutdown packet which should result is socket closure via callback. |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | close virtual | Closes the underlying socket. |
function | address virtual const | The locally bound address. |
function | peerAddress virtual const | The connected peer address. |
function | transport virtual const | The transport protocol: TCP, UDP or SSLTCP. |
function | setError virtual | Sets the socket error. |
function | error virtual const | Return the socket error if any. |
function | closed virtual const | Returns true if the native socket handle is closed. |
function | loop virtual const | Returns the socket event loop. |
variable | _af | |
function | init virtual | Initializes the underlying socket context. |
function | reset virtual | Resets the socket context for reuse. |
typedef | Ptr | |
typedef | Vec |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Public Attributes
| Return | Name | Description |
|---|---|---|
LocalSignal< void(const net::TCPSocket::Ptr &)> | AcceptConnection | Fired when a new client connection is accepted; carries a shared_ptr to the new socket. |
{#acceptconnection-1}
AcceptConnection
LocalSignal< void(const net::TCPSocket::Ptr &)> AcceptConnection
Defined in src/net/include/icy/net/tcpsocket.h:149
Fired when a new client connection is accepted; carries a shared_ptr to the new socket.
Public Methods
| Return | Name | Description |
|---|---|---|
TCPSocket | Constructs the TCPSocket and initializes the underlying libuv handle. | |
TCPSocket | Deleted constructor. | |
TCPSocket | Deleted constructor. | |
bool | shutdown virtual nodiscard override | Sends a TCP shutdown request; the socket closes after the peer acknowledges. |
void | close virtual override | Closes the socket immediately, releasing all associated resources. |
void | connect virtual override | Connects to peerAddress using a libuv connect request. On success, calls onConnect(); on failure, calls setUVError(). |
void | connect virtual override | Resolves host via DNS (or maps "localhost"), then connects. |
ssize_t | send virtual nodiscard override | Writes len bytes to the connected peer. |
ssize_t | sendOwned virtual nodiscard override | Sends an owned payload buffer to the connected peer. |
ssize_t | send virtual nodiscard override | Writes len bytes; peerAddress is ignored for TCP (connected stream). |
ssize_t | sendOwned virtual nodiscard override | |
void | bind virtual override | Binds the socket to address. Resets and reinitializes the handle if the address family changes. |
void | listen virtual override | Starts listening for incoming connections with the given backlog. |
void | acceptConnection virtual | Accepts the next pending client connection and fires AcceptConnection. |
bool | setReusePort nodiscard | Enables SO_REUSEPORT on Linux kernel >= 3.9 for multi-thread load balancing. Must be called after bind(). No-op and returns false on unsupported platforms. |
bool | setNoDelay nodiscard | Enables or disables TCP_NODELAY (Nagle's algorithm). |
bool | setKeepAlive nodiscard | Enables or disables TCP keep-alive probes. |
bool | setSimultaneousAccepts nodiscard | Enables or disables simultaneous accepts on Windows. No-op and returns false on non-Windows platforms. |
void | setMode | Sets the socket mode (ServerSide or ClientSide). |
SocketMode | mode const | Returns the current socket mode. |
void | setError virtual override | Sets the socket error; ignores the call if an error is already recorded. Setting an error causes the socket to close. |
const icy::Error & | error virtual const override | Returns the current socket error, if any. |
bool | closed virtual const override | Returns true if the native socket handle is closed. |
net::Address | address virtual const override | Returns the IP address and port number of the socket. A wildcard address is returned if the socket is not connected. |
net::Address | peerAddress virtual const override | Returns the IP address and port number of the peer socket. A wildcard address is returned if the socket is not connected. |
net::TransportType | transport virtual const override | Returns the TCP transport protocol. |
uv::Loop * | loop virtual const override | Returns the event loop associated with this socket. |
void | onConnect virtual | Called by the stream layer when the TCP connection is established. |
void | onRead virtual override | Called by the stream layer with raw received bytes; wraps them in a MutableBuffer. |
void | onRecv virtual | Dispatches a received buffer to all socket adapters via onSocketRecv. |
void | onError virtual override | Dispatches the error to adapters and closes the socket. |
void | onClose virtual override | Dispatches the close event to all socket adapters. |
{#tcpsocket-1}
TCPSocket
TCPSocket(uv::Loop * loop = uv::defaultLoop())
Defined in src/net/include/icy/net/tcpsocket.h:39
Constructs the TCPSocket and initializes the underlying libuv handle.
Parameters
loopEvent loop to use; defaults to the default loop.
{#tcpsocket-2}
TCPSocket
TCPSocket(const TCPSocket &) = delete
Defined in src/net/include/icy/net/tcpsocket.h:42
Deleted constructor.
{#tcpsocket-3}
TCPSocket
TCPSocket(TCPSocket &&) = delete
Defined in src/net/include/icy/net/tcpsocket.h:44
Deleted constructor.
{#shutdown-5}
shutdown
virtual nodiscard override
[[nodiscard]] virtual bool shutdown() override
Defined in src/net/include/icy/net/tcpsocket.h:49
Sends a TCP shutdown request; the socket closes after the peer acknowledges.
Returns
true if the shutdown request was queued successfully.
Reimplements
{#close-15}
close
virtual override
virtual void close() override
Defined in src/net/include/icy/net/tcpsocket.h:52
Closes the socket immediately, releasing all associated resources.
Reimplements
Reimplemented by
{#connect-7}
connect
virtual override
virtual void connect(const net::Address & peerAddress) override
Defined in src/net/include/icy/net/tcpsocket.h:57
Connects to peerAddress using a libuv connect request. On success, calls onConnect(); on failure, calls setUVError().
Parameters
peerAddressThe remote address to connect to.
Reimplements
Reimplemented by
{#connect-8}
connect
virtual override
virtual void connect(std::string_view host, uint16_t port) override
Defined in src/net/include/icy/net/tcpsocket.h:62
Resolves host via DNS (or maps "localhost"), then connects.
Parameters
-
hostHostname or IP address string. -
portDestination port.
Reimplements
Reimplemented by
{#send-4}
send
virtual nodiscard override
[[nodiscard]] virtual ssize_t send(const char * data, size_t len, int flags = 0) override
Defined in src/net/include/icy/net/tcpsocket.h:69
Writes len bytes to the connected peer.
Parameters
-
dataPointer to the data to send. -
lenNumber of bytes to send. -
flagsReserved; currently unused.
Returns
Number of bytes sent, or -1 on error.
Reimplements
Reimplemented by
{#sendowned-6}
sendOwned
virtual nodiscard override
[[nodiscard]] virtual ssize_t sendOwned(Buffer && buffer, int flags = 0) override
Defined in src/net/include/icy/net/tcpsocket.h:70
Sends an owned payload buffer to the connected peer.
Reimplements
Reimplemented by
{#send-5}
send
virtual nodiscard override
[[nodiscard]] virtual ssize_t send(const char * data, size_t len, const net::Address & peerAddress, int flags = 0) override
Defined in src/net/include/icy/net/tcpsocket.h:78
Writes len bytes; peerAddress is ignored for TCP (connected stream).
Parameters
-
dataPointer to the data to send. -
lenNumber of bytes to send. -
peerAddressIgnored; present for interface conformance. -
flagsReserved; currently unused.
Returns
Number of bytes sent, or -1 on error.
Reimplements
Reimplemented by
{#sendowned-7}
sendOwned
virtual nodiscard override
[[nodiscard]] virtual ssize_t sendOwned(Buffer && buffer, const net::Address & peerAddress, int flags = 0) override
Defined in src/net/include/icy/net/tcpsocket.h:79
Reimplements
Reimplemented by
{#bind-2}
bind
virtual override
virtual void bind(const net::Address & address, unsigned flags = 0) override
Defined in src/net/include/icy/net/tcpsocket.h:85
Binds the socket to address. Resets and reinitializes the handle if the address family changes.
Parameters
-
addressLocal address to bind to. -
flagsOptional bind flags (e.g. UV_TCP_IPV6ONLY is added automatically for IPv6).
Reimplements
Reimplemented by
{#listen-2}
listen
virtual override
virtual void listen(int backlog = 64) override
Defined in src/net/include/icy/net/tcpsocket.h:89
Starts listening for incoming connections with the given backlog.
Parameters
backlogMaximum length of the pending connection queue.
Reimplements
Reimplemented by
{#acceptconnection-2}
acceptConnection
virtual
virtual void acceptConnection()
Defined in src/net/include/icy/net/tcpsocket.h:92
Accepts the next pending client connection and fires AcceptConnection.
Reimplemented by
{#setreuseport}
setReusePort
nodiscard
[[nodiscard]] bool setReusePort()
Defined in src/net/include/icy/net/tcpsocket.h:97
Enables SO_REUSEPORT on Linux kernel >= 3.9 for multi-thread load balancing. Must be called after bind(). No-op and returns false on unsupported platforms.
Returns
true if the socket option was set successfully.
{#setnodelay}
setNoDelay
nodiscard
[[nodiscard]] bool setNoDelay(bool enable)
Defined in src/net/include/icy/net/tcpsocket.h:102
Enables or disables TCP_NODELAY (Nagle's algorithm).
Parameters
enabletrue to disable Nagle's algorithm (lower latency).
Returns
true if the option was set successfully.
{#setkeepalive}
setKeepAlive
nodiscard
[[nodiscard]] bool setKeepAlive(bool enable, int delay)
Defined in src/net/include/icy/net/tcpsocket.h:108
Enables or disables TCP keep-alive probes.
Parameters
-
enabletrue to enable keep-alive. -
delayInitial delay in seconds before the first keep-alive probe.
Returns
true if the option was set successfully.
{#setsimultaneousaccepts}
setSimultaneousAccepts
nodiscard
[[nodiscard]] bool setSimultaneousAccepts(bool enable)
Defined in src/net/include/icy/net/tcpsocket.h:114
Enables or disables simultaneous accepts on Windows. No-op and returns false on non-Windows platforms.
Parameters
enabletrue to enable simultaneous accepts.
Returns
true if the option was set successfully.
{#setmode}
setMode
void setMode(SocketMode mode)
Defined in src/net/include/icy/net/tcpsocket.h:118
Sets the socket mode (ServerSide or ClientSide).
Parameters
modeThe mode to assign.
{#mode}
mode
const
SocketMode mode() const
Defined in src/net/include/icy/net/tcpsocket.h:121
Returns the current socket mode.
{#seterror-2}
setError
virtual override
virtual void setError(const icy::Error & err) override
Defined in src/net/include/icy/net/tcpsocket.h:126
Sets the socket error; ignores the call if an error is already recorded. Setting an error causes the socket to close.
Parameters
errThe error to record.
Reimplements
{#error-7}
error
virtual const override
virtual const icy::Error & error() const override
Defined in src/net/include/icy/net/tcpsocket.h:129
Returns the current socket error, if any.
Reimplements
{#closed-2}
closed
virtual const override
virtual bool closed() const override
Defined in src/net/include/icy/net/tcpsocket.h:132
Returns true if the native socket handle is closed.
Reimplements
{#address-9}
address
virtual const override
virtual net::Address address() const override
Defined in src/net/include/icy/net/tcpsocket.h:136
Returns the IP address and port number of the socket. A wildcard address is returned if the socket is not connected.
Reimplements
{#peeraddress-2}
peerAddress
virtual const override
virtual net::Address peerAddress() const override
Defined in src/net/include/icy/net/tcpsocket.h:140
Returns the IP address and port number of the peer socket. A wildcard address is returned if the socket is not connected.
Reimplements
{#transport-2}
transport
virtual const override
virtual net::TransportType transport() const override
Defined in src/net/include/icy/net/tcpsocket.h:143
Returns the TCP transport protocol.
Reimplements
{#loop-4}
loop
virtual const override
virtual uv::Loop * loop() const override
Defined in src/net/include/icy/net/tcpsocket.h:146
Returns the event loop associated with this socket.
Reimplements
{#onconnect-1}
onConnect
virtual
virtual void onConnect()
Defined in src/net/include/icy/net/tcpsocket.h:153
Called by the stream layer when the TCP connection is established.
Reimplemented by
{#onread-1}
onRead
virtual override
virtual void onRead(const char * data, size_t len) override
Defined in src/net/include/icy/net/tcpsocket.h:158
Called by the stream layer with raw received bytes; wraps them in a MutableBuffer.
Parameters
-
dataPointer to received bytes. -
lenNumber of bytes received.
Reimplements
Reimplemented by
{#onrecv}
onRecv
virtual
virtual void onRecv(const MutableBuffer & buf)
Defined in src/net/include/icy/net/tcpsocket.h:162
Dispatches a received buffer to all socket adapters via onSocketRecv.
Parameters
bufThe buffer containing the received data.
{#onerror-1}
onError
virtual override
virtual void onError(const icy::Error & error) override
Defined in src/net/include/icy/net/tcpsocket.h:166
Dispatches the error to adapters and closes the socket.
Parameters
errorThe error that occurred.
Reimplements
{#onclose-1}
onClose
virtual override
virtual void onClose() override
Defined in src/net/include/icy/net/tcpsocket.h:169
Dispatches the close event to all socket adapters.
Reimplements
Protected Attributes
| Return | Name | Description |
|---|---|---|
SocketMode | _mode | |
net::Address | _peerAddress | Cached peer address (avoids syscall per recv). |
{#_mode-1}
_mode
SocketMode _mode
Defined in src/net/include/icy/net/tcpsocket.h:175
{#_peeraddress}
_peerAddress
net::Address _peerAddress
Defined in src/net/include/icy/net/tcpsocket.h:176
Cached peer address (avoids syscall per recv).
Protected Methods
| Return | Name | Description |
|---|---|---|
void | init virtual override | Initializes the underlying socket context. |
void | reset virtual override | Resets the socket context for reuse. |
{#init-5}
init
virtual override
virtual void init() override
Defined in src/net/include/icy/net/tcpsocket.h:172
Initializes the underlying socket context.
Reimplements
{#reset-5}
reset
virtual override
virtual void reset() override
Defined in src/net/include/icy/net/tcpsocket.h:173
Resets the socket context for reuse.
Reimplements
Public Types
| Name | Description |
|---|---|
Ptr | |
Vec |
{#ptr-9}
Ptr
using Ptr = std::shared_ptr< TCPSocket >
Defined in src/net/include/icy/net/tcpsocket.h:34
{#vec-2}
Vec
using Vec = std::vector< Ptr >
Defined in src/net/include/icy/net/tcpsocket.h:35
{#transaction}
Transaction
#include <icy/net/transaction.h>
template<class PacketT>
class Transaction
Defined in src/net/include/icy/net/transaction.h:27
Inherits:
PacketTransaction< PacketT >,PacketSocketEmitter
Request/response helper for packet types emitted from a socket.
List of all members
| Name | Kind | Owner |
|---|---|---|
IntrusivePtr | friend | Declared here |
Transaction | function | Declared here |
send | function | Declared here |
cancel | function | Declared here |
dispose | function | Declared here |
peerAddress | function | Declared here |
_peerAddress | variable | Declared here |
onPacket | function | Declared here |
onResponse | function | Declared here |
checkResponse | function | Declared here |
BaseT | typedef | Declared here |
Ptr | typedef | Inherited from PacketTransaction |
IntrusivePtr | friend | Inherited from PacketTransaction |
_request | variable | Inherited from PacketTransaction |
_response | variable | Inherited from PacketTransaction |
_timer | variable | Inherited from PacketTransaction |
_retries | variable | Inherited from PacketTransaction |
_attempts | variable | Inherited from PacketTransaction |
_disposed | variable | Inherited from PacketTransaction |
PacketTransaction | function | Inherited from PacketTransaction |
PacketTransaction | function | Inherited from PacketTransaction |
send | function | Inherited from PacketTransaction |
cancel | function | Inherited from PacketTransaction |
cancelled | function | Inherited from PacketTransaction |
dispose | function | Inherited from PacketTransaction |
disposed | function | Inherited from PacketTransaction |
canResend | function | Inherited from PacketTransaction |
attempts | function | Inherited from PacketTransaction |
retries | function | Inherited from PacketTransaction |
request | function | Inherited from PacketTransaction |
request | function | Inherited from PacketTransaction |
response | function | Inherited from PacketTransaction |
response | function | Inherited from PacketTransaction |
~PacketTransaction | function | Inherited from PacketTransaction |
onStateChange | function | Inherited from PacketTransaction |
handlePotentialResponse | function | Inherited from PacketTransaction |
checkResponse | function | Inherited from PacketTransaction |
onResponse | function | Inherited from PacketTransaction |
onTimeout | function | Inherited from PacketTransaction |
send | function | Inherited from Sendable |
cancel | function | Inherited from Sendable |
StateChange | variable | Inherited from Stateful |
_state | variable | Inherited from Stateful |
Stateful | function | Inherited from Stateful |
~Stateful | function | Inherited from Stateful |
stateEquals | function | Inherited from Stateful |
stateBetween | function | Inherited from Stateful |
state | function | Inherited from Stateful |
state | function | Inherited from Stateful |
beforeStateChange | function | Inherited from Stateful |
onStateChange | function | Inherited from Stateful |
setState | function | Inherited from Stateful |
setState | function | Inherited from Stateful |
_refCount | variable | Inherited from RefCounted |
RefCounted | function | Inherited from RefCounted |
RefCounted | function | Inherited from RefCounted |
operator= | function | Inherited from RefCounted |
addRef | function | Inherited from RefCounted |
releaseRef | function | Inherited from RefCounted |
refCount | function | Inherited from RefCounted |
~RefCounted | function | Inherited from RefCounted |
factory | variable | Inherited from PacketSocketEmitter |
PacketSocketEmitter | function | Inherited from PacketSocketEmitter |
onSocketRecv | function | Inherited from PacketSocketEmitter |
onPacket | function | Inherited from PacketSocketEmitter |
Connect | variable | Inherited from SocketEmitter |
Recv | variable | Inherited from SocketEmitter |
Error | variable | Inherited from SocketEmitter |
Close | variable | Inherited from SocketEmitter |
impl | variable | Inherited from SocketEmitter |
SocketEmitter | function | Inherited from SocketEmitter |
SocketEmitter | function | Inherited from SocketEmitter |
~SocketEmitter | function | Inherited from SocketEmitter |
addReceiver | function | Inherited from SocketEmitter |
removeReceiver | function | Inherited from SocketEmitter |
swap | function | Inherited from SocketEmitter |
as | function | Inherited from SocketEmitter |
operator-> | function | Inherited from SocketEmitter |
onSocketConnect | function | Inherited from SocketEmitter |
onSocketRecv | function | Inherited from SocketEmitter |
onSocketError | function | Inherited from SocketEmitter |
onSocketClose | function | Inherited from SocketEmitter |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from PacketTransaction
| Kind | Name | Description |
|---|---|---|
typedef | Ptr | |
friend | IntrusivePtr | |
variable | _request | |
variable | _response | |
variable | _timer | The request timeout callback. |
variable | _retries | The maximum number of attempts before the transaction is considered failed. |
variable | _attempts | The number of times the transaction has been sent. |
variable | _disposed | |
function | PacketTransaction inline | |
function | PacketTransaction inline | |
function | send virtual inline override | Starts the transaction timer and sends the request. Overriding classes should implement send logic here. |
function | cancel virtual inline override | Cancellation means that the agent will not retransmit the request, will not treat the lack of response to be a failure, but will wait the duration of the transaction timeout for a response. Transitions the transaction to the Cancelled state. |
function | cancelled const inline | |
function | dispose virtual inline | Stops the timer and unregisters callbacks. Does NOT delete the object; the IntrusivePtr destructor handles deletion when the last reference is released. Safe to call multiple times. |
function | disposed const inline nodiscard | |
function | canResend virtual inline | |
function | attempts const inline | |
function | retries const inline | |
function | request inline | |
function | request const inline | |
function | response inline | |
function | response const inline | |
function | ~PacketTransaction virtual inline | |
function | onStateChange virtual inline override | Post state change hook. Calls dispose() on terminal states to stop the timer, but does not delete the object; IntrusivePtr handles that. |
function | handlePotentialResponse virtual inline | Processes a potential response candidate and updates the state accordingly. |
function | checkResponse virtual | Checks a potential response candidate and returns true on successful match. |
function | onResponse virtual inline | Called when a successful response is received. |
function | onTimeout virtual inline | Called by the timer when the transaction timeout elapses. Retransmits if retries remain, otherwise transitions to Failed. |
Inherited from Sendable
| Kind | Name | Description |
|---|---|---|
function | send virtual | Initiates the send operation. |
function | cancel virtual | Cancels a pending send operation. |
Inherited from Stateful
| Kind | Name | Description |
|---|---|---|
variable | StateChange | Signals when the state changes. |
variable | _state | |
function | Stateful inline | |
function | ~Stateful virtual inline | |
function | stateEquals virtual const inline | Returns true if the current state ID equals the given ID. |
function | stateBetween virtual const inline | Returns true if the current state ID is in the inclusive range [lid, rid]. |
function | state virtual inline | Returns a mutable reference to the current state. |
function | state virtual const inline | Returns a copy of the current state. |
function | beforeStateChange virtual inline | Override to handle pre state change logic. Return false to prevent state change. |
function | onStateChange virtual inline | Override to handle post state change logic. |
function | setState virtual inline | Sets the state and sends the state signal if the state change was successful. |
function | setState virtual inline | Sets the state and sends the state signal if the state change was successful. |
Inherited from RefCounted
| Kind | Name | Description |
|---|---|---|
variable | _refCount | |
function | RefCounted | Defaulted constructor. |
function | RefCounted inline noexcept | |
function | operator= inline noexcept | |
function | addRef const inline noexcept | Increments the reference count. Called by IntrusivePtr on acquisition. |
function | releaseRef const inline noexcept | Decrements the reference count. |
function | refCount const inline nodiscard noexcept | Returns the current reference count. |
function | ~RefCounted | Defaulted destructor. |
Inherited from PacketSocketEmitter
| Kind | Name | Description |
|---|---|---|
variable | factory | The packet factory. |
function | PacketSocketEmitter | Creates the PacketSocketEmitter and attaches it to the given socket. |
function | onSocketRecv virtual override | Parses raw received data into packets via the factory and forwards each parsed packet to onPacket(). Returns true if propagation should stop. |
function | onPacket virtual | Process a parsed packet. Returns true to stop propagation. |
Inherited from SocketEmitter
| Kind | Name | Description |
|---|---|---|
variable | Connect | Signals that the socket is connected. |
variable | Recv | Signals when data is received by the socket. |
variable | Error | Signals that the socket is closed in error. This signal will be sent just before the Closed signal. |
variable | Close | Signals that the underlying socket is closed. |
variable | impl | Pointer to the underlying socket. Sent data will be proxied to this socket. |
function | SocketEmitter | Creates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver. |
function | SocketEmitter | Copy constructor; copies all signal connections and attaches to the same socket. |
function | ~SocketEmitter virtual noexcept | Destroys the SocketAdapter. |
function | addReceiver virtual override | Attaches a SocketAdapter as a receiver; wires it to all four socket signals. |
function | removeReceiver virtual override | Detaches a SocketAdapter from all four socket signals. |
function | swap virtual | Replaces the underlying socket with socket. |
function | as inline | Returns the underlying socket cast to type T, or nullptr if the cast fails. |
function | operator-> const inline | Returns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer. |
function | onSocketConnect virtual override | Forwards the connect event to chained adapters, then fires the Connect signal. |
function | onSocketRecv virtual override | Forwards the recv event to chained adapters, then fires the Recv signal. |
function | onSocketError virtual override | Forwards the error event to chained adapters, then fires the Error signal. |
function | onSocketClose virtual override | Forwards the close event to chained adapters, then fires the Close signal. |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Friends
| Name | Description |
|---|---|
icy::IntrusivePtr |
{#icy-intrusiveptr}
icy::IntrusivePtr
template<typename U> friend class icy::IntrusivePtr
Defined in src/net/include/icy/net/transaction.h:81
Public Methods
| Return | Name | Description |
|---|---|---|
Transaction inline | Constructs a Transaction on the given socket targeting peerAddress. | |
bool | send virtual inline override | Sends the request packet to the peer address and starts the timeout timer. Sets state to Failed and returns false if the packet could not be sent. |
void | cancel virtual inline override | Cancels the transaction and stops the timeout timer. |
void | dispose virtual inline override | Stops the timer and unregisters callbacks. |
Address | peerAddress const inline | Returns the remote peer address used for this transaction. |
{#transaction-1}
Transaction
inline
inline Transaction(const net::Socket::Ptr & socket, const Address & peerAddress, int timeout = 10000, int retries = 1)
Defined in src/net/include/icy/net/transaction.h:39
Constructs a Transaction on the given socket targeting peerAddress.
Parameters
-
socketThe socket to send/receive packets on. -
peerAddressThe remote address for the request and response matching. -
timeoutMilliseconds to wait for a response before failing. -
retriesNumber of additional send attempts on timeout.
{#send-6}
send
virtual inline override
virtual inline bool send() override
Defined in src/net/include/icy/net/transaction.h:51
Sends the request packet to the peer address and starts the timeout timer. Sets state to Failed and returns false if the packet could not be sent.
Returns
true if the packet was sent and the timer started successfully.
Reimplements
{#cancel}
cancel
virtual inline override
virtual inline void cancel() override
Defined in src/net/include/icy/net/transaction.h:61
Cancels the transaction and stops the timeout timer.
Reimplements
{#dispose}
dispose
virtual inline override
virtual inline void dispose() override
Defined in src/net/include/icy/net/transaction.h:68
Stops the timer and unregisters callbacks.
Reimplements
{#peeraddress-3}
peerAddress
const inline
inline Address peerAddress() const
Defined in src/net/include/icy/net/transaction.h:75
Returns the remote peer address used for this transaction.
Protected Attributes
| Return | Name | Description |
|---|---|---|
Address | _peerAddress |
{#_peeraddress-1}
_peerAddress
Address _peerAddress
Defined in src/net/include/icy/net/transaction.h:118
Protected Methods
| Return | Name | Description |
|---|---|---|
bool | onPacket virtual inline override | Checks whether packet is a matching response for the pending request. If it matches, the transaction completes; socket data propagation stops. |
void | onResponse virtual inline override | Called when a confirmed response is received; emits the response via PacketSignal. |
bool | checkResponse virtual inline override | Returns true if packet is a valid response for this transaction. |
{#onpacket-1}
onPacket
virtual inline override
virtual inline bool onPacket(IPacket & packet) override
Defined in src/net/include/icy/net/transaction.h:89
Checks whether packet is a matching response for the pending request. If it matches, the transaction completes; socket data propagation stops.
Parameters
packetThe received packet to test.
Returns
true to stop further propagation of the socket data event.
Reimplements
{#onresponse}
onResponse
virtual inline override
virtual inline void onResponse() override
Defined in src/net/include/icy/net/transaction.h:97
Called when a confirmed response is received; emits the response via PacketSignal.
Reimplements
Reimplemented by
{#checkresponse}
checkResponse
virtual inline override
virtual inline bool checkResponse(const PacketT & packet) override
Defined in src/net/include/icy/net/transaction.h:110
Returns true if packet is a valid response for this transaction.
The base implementation matches the local socket address against the PacketInfo socket address and the stored peer address against the PacketInfo peer address. Subclasses may override for stricter matching.
Parameters
packetThe candidate response packet.
Returns
true if the packet satisfies the response criteria.
Reimplements
Public Types
| Name | Description |
|---|---|
BaseT |
{#baset}
BaseT
using BaseT = PacketTransaction< PacketT >
Defined in src/net/include/icy/net/transaction.h:31
{#udpsocket}
UDPSocket
#include <icy/net/udpsocket.h>
class UDPSocket
Defined in src/net/include/icy/net/udpsocket.h:28
Inherits:
Handle< uv_udp_t >,Socket
UDP socket implementation.
List of all members
| Name | Kind | Owner |
|---|---|---|
UDPSocket | function | Declared here |
UDPSocket | function | Declared here |
UDPSocket | function | Declared here |
connect | function | Declared here |
connect | function | Declared here |
close | function | Declared here |
bind | function | Declared here |
send | function | Declared here |
sendOwned | function | Declared here |
send | function | Declared here |
sendOwned | function | Declared here |
setBroadcast | function | Declared here |
setMulticastLoop | function | Declared here |
setMulticastTTL | function | Declared here |
address | function | Declared here |
peerAddress | function | Declared here |
transport | function | Declared here |
setError | function | Declared here |
error | function | Declared here |
closed | function | Declared here |
loop | function | Declared here |
onRecv | function | Declared here |
_peer | variable | Declared here |
_buffer | variable | Declared here |
init | function | Declared here |
reset | function | Declared here |
onError | function | Declared here |
onClose | function | Declared here |
recvStart | function | Declared here |
recvStop | function | Declared here |
Ptr | typedef | Declared here |
Vec | typedef | Declared here |
Handle | function | Inherited from Handle |
init | function | Inherited from Handle |
invoke | function | Inherited from Handle |
invokeOrThrow | function | Inherited from Handle |
close | function | Inherited from Handle |
ref | function | Inherited from Handle |
unref | function | Inherited from Handle |
initialized | function | Inherited from Handle |
active | function | Inherited from Handle |
closing | function | Inherited from Handle |
closed | function | Inherited from Handle |
error | function | Inherited from Handle |
setError | function | Inherited from Handle |
setUVError | function | Inherited from Handle |
setAndThrowError | function | Inherited from Handle |
throwLastError | function | Inherited from Handle |
loop | function | Inherited from Handle |
reset | function | Inherited from Handle |
get | function | Inherited from Handle |
tid | function | Inherited from Handle |
context | function | Inherited from Handle |
setCloseCleanup | function | Inherited from Handle |
clearCloseCleanup | function | Inherited from Handle |
assertThread | function | Inherited from Handle |
_loop | variable | Inherited from Handle |
_context | variable | Inherited from Handle |
_tid | variable | Inherited from Handle |
_error | variable | Inherited from Handle |
onError | function | Inherited from Handle |
onClose | function | Inherited from Handle |
Handle | function | Inherited from Handle |
Handle | function | Inherited from Handle |
Type | typedef | Inherited from Handle |
opaque | variable | Inherited from Socket |
Socket | function | Inherited from Socket |
Socket | function | Inherited from Socket |
Socket | function | Inherited from Socket |
connect | function | Inherited from Socket |
connect | function | Inherited from Socket |
bind | function | Inherited from Socket |
listen | function | Inherited from Socket |
shutdown | function | Inherited from Socket |
sendOwned | function | Inherited from Socket |
sendOwned | function | Inherited from Socket |
close | function | Inherited from Socket |
address | function | Inherited from Socket |
peerAddress | function | Inherited from Socket |
transport | function | Inherited from Socket |
setError | function | Inherited from Socket |
error | function | Inherited from Socket |
closed | function | Inherited from Socket |
loop | function | Inherited from Socket |
_af | variable | Inherited from Socket |
init | function | Inherited from Socket |
reset | function | Inherited from Socket |
Ptr | typedef | Inherited from Socket |
Vec | typedef | Inherited from Socket |
priority | variable | Inherited from SocketAdapter |
SocketAdapter | function | Inherited from SocketAdapter |
~SocketAdapter | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
send | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendOwned | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
sendPacket | function | Inherited from SocketAdapter |
setSender | function | Inherited from SocketAdapter |
sender | function | Inherited from SocketAdapter |
addReceiver | function | Inherited from SocketAdapter |
removeReceiver | function | Inherited from SocketAdapter |
hasReceiver | function | Inherited from SocketAdapter |
receivers | function | Inherited from SocketAdapter |
onSocketConnect | function | Inherited from SocketAdapter |
onSocketRecv | function | Inherited from SocketAdapter |
onSocketError | function | Inherited from SocketAdapter |
onSocketClose | function | Inherited from SocketAdapter |
_sender | variable | Inherited from SocketAdapter |
_receivers | variable | Inherited from SocketAdapter |
_dirty | variable | Inherited from SocketAdapter |
cleanupReceivers | function | Inherited from SocketAdapter |
Inherited from Handle
| Kind | Name | Description |
|---|---|---|
function | Handle inline | Construct the handle bound to the given event loop. |
function | init inline | Initialize the underlying libuv handle by calling f with the loop, the raw handle pointer, and any additional args. |
function | invoke inline | Invoke a libuv function f with args on the initialized handle. |
function | invokeOrThrow inline | Invoke a libuv function f with args, throwing on failure. |
function | close virtual inline | Close and destroy the handle. |
function | ref inline | Re-reference the handle with the event loop after a previous [unref()](uv.md#unref). |
function | unref inline | Unreference the handle from the event loop. |
function | initialized const inline | Return true if the handle has been successfully initialized via [init()](uv.md#init-2). |
function | active virtual const inline | Return true when the handle is active (libuv uv_is_active). |
function | closing virtual const inline | Return true if uv_close has been called and the handle is awaiting its close callback (libuv uv_is_closing). |
function | closed virtual const inline | Return true if the handle has been fully closed (context released). |
function | error const inline | Return the last error set on this handle, or a default-constructed [Error](base.md#error) if no error has occurred. |
function | setError virtual inline | Set the error state and invoke [onError()](uv.md#onerror). |
function | setUVError inline | Translate a libuv error code into an [Error](base.md#error) and call [setError()](uv.md#seterror). |
function | setAndThrowError inline | Set the error state from a libuv error code and throw a std::runtime_error. |
function | throwLastError inline | Throw a std::runtime_error if the handle currently holds an error. |
function | loop const inline | Return the event loop this handle is bound to. |
function | reset inline | Close the current handle (if open) and allocate a fresh [Context](uv.md#context-1), leaving the handle ready to be re-initialized via [init()](uv.md#init-2). |
function | get const inline | Return the raw libuv handle pointer cast to [Handle](uv.md#handle-2). |
function | tid const inline | Return the ID of the thread that constructed this handle. |
function | context const inline | Return the raw [Context](uv.md#context-1) that owns the libuv handle memory. |
function | setCloseCleanup inline | |
function | clearCloseCleanup inline | |
function | assertThread const inline | Throw std::logic_error if called from any thread other than the thread that constructed this handle. |
variable | _loop | |
variable | _context | |
variable | _tid | |
variable | _error | |
function | onError virtual inline | Called by [setError()](uv.md#seterror) after the error state has been updated. |
function | onClose virtual inline | Called by [close()](uv.md#close-11) after the context has been released. |
function | Handle | NonCopyable and NonMovable. |
function | Handle | Deleted constructor. |
typedef | Type | Define the native handle type. |
Inherited from Socket
| Kind | Name | Description |
|---|---|---|
variable | opaque | Optional client data. |
function | Socket | Defaulted constructor. |
function | Socket | Deleted constructor. |
function | Socket | Deleted constructor. |
function | connect virtual | Connects to the given peer IP address. |
function | connect virtual | Resolves and connects to the given host address. |
function | bind virtual | Bind a local address to the socket. The address may be IPv4 or IPv6 (if supported). |
function | listen virtual inline | Listens the socket on the given address. |
function | shutdown virtual inline nodiscard | Sends the shutdown packet which should result is socket closure via callback. |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | close virtual | Closes the underlying socket. |
function | address virtual const | The locally bound address. |
function | peerAddress virtual const | The connected peer address. |
function | transport virtual const | The transport protocol: TCP, UDP or SSLTCP. |
function | setError virtual | Sets the socket error. |
function | error virtual const | Return the socket error if any. |
function | closed virtual const | Returns true if the native socket handle is closed. |
function | loop virtual const | Returns the socket event loop. |
variable | _af | |
function | init virtual | Initializes the underlying socket context. |
function | reset virtual | Resets the socket context for reuse. |
typedef | Ptr | |
typedef | Vec |
Inherited from SocketAdapter
| Kind | Name | Description |
|---|---|---|
variable | priority | The priority of this adapter for STL sort operations. |
function | SocketAdapter | Creates the SocketAdapter. |
function | ~SocketAdapter virtual noexcept | Destroys the SocketAdapter. |
function | send virtual nodiscard | Sends the given data buffer to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | send virtual nodiscard | |
function | sendOwned virtual nodiscard | Sends an owned payload buffer to the connected peer. |
function | sendOwned virtual nodiscard | |
function | sendPacket virtual | Sends the given packet to the connected peer. Returns the number of bytes sent or -1 on error. No exception will be thrown. For TCP sockets the given peer address must match the connected peer address. |
function | sendPacket virtual | |
function | sendPacket virtual | Sends the given packet to the connected peer. This method provides delegate compatibility, and unlike other send methods throws an exception if the underlying socket is closed. |
function | setSender virtual | Sets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default. |
function | sender | Returns the output SocketAdapter pointer. |
function | addReceiver virtual | Sets the pointer to the incoming data adapter. Events proxy data to this adapter by default. |
function | removeReceiver virtual | Remove the given receiver. |
function | hasReceiver virtual | Returns true if the given receiver is connected. |
function | receivers | Returns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list. |
function | onSocketConnect virtual | Called when the socket establishes a connection. Forwards the event to all registered receivers in priority order. Override to intercept before the application sees the event. |
function | onSocketRecv virtual | Called when data is received from the socket. Forwards the event to all registered receivers in priority order. |
function | onSocketError virtual | Called when the socket encounters an error. Forwards the event to all registered receivers in priority order. |
function | onSocketClose virtual | Called when the socket is closed. Forwards the event to all registered receivers in priority order. |
variable | _sender | |
variable | _receivers | |
variable | _dirty | |
function | cleanupReceivers virtual |
Public Methods
| Return | Name | Description |
|---|---|---|
UDPSocket | Constructs the UDPSocket and initializes the underlying libuv handle. | |
UDPSocket | Deleted constructor. | |
UDPSocket | Deleted constructor. | |
void | connect virtual override | Records the peer address and fires the Connect signal to mimic TCP socket behaviour. UDP is connectionless; this call does not send any data. |
void | connect virtual override | Resolves host via DNS (or maps "localhost"), then calls connect(Address). |
void | close virtual override | Stops receiving and closes the underlying UDP handle. |
void | bind virtual override | Binds the socket to address and starts the receive loop. |
ssize_t | send virtual nodiscard override | Sends len bytes to the previously connected peer address. Returns -1 if no peer address has been set. |
ssize_t | sendOwned virtual nodiscard override | Sends an owned payload buffer to the connected peer. |
ssize_t | send virtual nodiscard override | Sends len bytes to peerAddress. Returns -1 if the socket is uninitialized or the address is not authorized. |
ssize_t | sendOwned virtual nodiscard override | |
bool | setBroadcast nodiscard | Enables or disables UDP broadcast. |
bool | setMulticastLoop nodiscard | Enables or disables IP multicast loopback. |
bool | setMulticastTTL nodiscard | Sets the IP multicast time-to-live (hop limit). |
net::Address | address virtual const override | Returns the locally bound address, or a wildcard address if unbound. |
net::Address | peerAddress virtual const override | Returns the connected peer address set by connect(), or a wildcard address if unconnected. |
net::TransportType | transport virtual const override | Returns the UDP transport protocol. |
void | setError virtual override | Sets the socket error and triggers close. |
const icy::Error & | error virtual const override | Returns the current socket error, if any. |
bool | closed virtual const override | Returns true if the native socket handle is closed. |
uv::Loop * | loop virtual const override | Returns the event loop associated with this socket. |
void | onRecv virtual | Dispatches a received datagram to all socket adapters via onSocketRecv. |
{#udpsocket-1}
UDPSocket
UDPSocket(uv::Loop * loop = uv::defaultLoop())
Defined in src/net/include/icy/net/udpsocket.h:37
Constructs the UDPSocket and initializes the underlying libuv handle.
Parameters
loopEvent loop to use; defaults to the default loop.
{#udpsocket-2}
UDPSocket
UDPSocket(const UDPSocket &) = delete
Defined in src/net/include/icy/net/udpsocket.h:40
Deleted constructor.
{#udpsocket-3}
UDPSocket
UDPSocket(UDPSocket &&) = delete
Defined in src/net/include/icy/net/udpsocket.h:42
Deleted constructor.
{#connect-9}
connect
virtual override
virtual void connect(const net::Address & peerAddress) override
Defined in src/net/include/icy/net/udpsocket.h:48
Records the peer address and fires the Connect signal to mimic TCP socket behaviour. UDP is connectionless; this call does not send any data.
Parameters
peerAddressThe remote address to associate with this socket.
Reimplements
{#connect-10}
connect
virtual override
virtual void connect(std::string_view host, uint16_t port) override
Defined in src/net/include/icy/net/udpsocket.h:53
Resolves host via DNS (or maps "localhost"), then calls connect(Address).
Parameters
-
hostHostname or IP address string. -
portDestination port.
Reimplements
{#close-16}
close
virtual override
virtual void close() override
Defined in src/net/include/icy/net/udpsocket.h:56
Stops receiving and closes the underlying UDP handle.
Reimplements
{#bind-3}
bind
virtual override
virtual void bind(const net::Address & address, unsigned flags = 0) override
Defined in src/net/include/icy/net/udpsocket.h:61
Binds the socket to address and starts the receive loop.
Parameters
-
addressLocal address to bind to. -
flagsOptional bind flags (UV_UDP_IPV6ONLY is added automatically for IPv6).
Reimplements
{#send-7}
send
virtual nodiscard override
[[nodiscard]] virtual ssize_t send(const char * data, size_t len, int flags = 0) override
Defined in src/net/include/icy/net/udpsocket.h:69
Sends len bytes to the previously connected peer address. Returns -1 if no peer address has been set.
Parameters
-
dataPointer to the data to send. -
lenNumber of bytes to send. -
flagsReserved; currently unused.
Returns
Number of bytes accepted for sending, or -1 on error.
Reimplements
{#sendowned-8}
sendOwned
virtual nodiscard override
[[nodiscard]] virtual ssize_t sendOwned(Buffer && buffer, int flags = 0) override
Defined in src/net/include/icy/net/udpsocket.h:70
Sends an owned payload buffer to the connected peer.
Reimplements
{#send-8}
send
virtual nodiscard override
[[nodiscard]] virtual ssize_t send(const char * data, size_t len, const net::Address & peerAddress, int flags = 0) override
Defined in src/net/include/icy/net/udpsocket.h:79
Sends len bytes to peerAddress. Returns -1 if the socket is uninitialized or the address is not authorized.
Parameters
-
dataPointer to the data to send. -
lenNumber of bytes to send. -
peerAddressDestination address; must match the connected peer if one is set. -
flagsReserved; currently unused.
Returns
Number of bytes accepted for sending, or -1 on error.
Reimplements
{#sendowned-9}
sendOwned
virtual nodiscard override
[[nodiscard]] virtual ssize_t sendOwned(Buffer && buffer, const net::Address & peerAddress, int flags = 0) override
Defined in src/net/include/icy/net/udpsocket.h:81
Reimplements
{#setbroadcast}
setBroadcast
nodiscard
[[nodiscard]] bool setBroadcast(bool flag)
Defined in src/net/include/icy/net/udpsocket.h:87
Enables or disables UDP broadcast.
Parameters
flagtrue to enable broadcast.
Returns
true if the option was set successfully.
{#setmulticastloop}
setMulticastLoop
nodiscard
[[nodiscard]] bool setMulticastLoop(bool flag)
Defined in src/net/include/icy/net/udpsocket.h:92
Enables or disables IP multicast loopback.
Parameters
flagtrue to enable multicast loopback.
Returns
true if the option was set successfully.
{#setmulticastttl}
setMulticastTTL
nodiscard
[[nodiscard]] bool setMulticastTTL(int ttl)
Defined in src/net/include/icy/net/udpsocket.h:98
Sets the IP multicast time-to-live (hop limit).
Parameters
ttlValue in the range [1, 255].
Returns
true if the option was set successfully.
Exceptions
std::invalid_argumentifttlis out of range.
{#address-10}
address
virtual const override
virtual net::Address address() const override
Defined in src/net/include/icy/net/udpsocket.h:101
Returns the locally bound address, or a wildcard address if unbound.
Reimplements
{#peeraddress-4}
peerAddress
virtual const override
virtual net::Address peerAddress() const override
Defined in src/net/include/icy/net/udpsocket.h:104
Returns the connected peer address set by connect(), or a wildcard address if unconnected.
Reimplements
{#transport-3}
transport
virtual const override
virtual net::TransportType transport() const override
Defined in src/net/include/icy/net/udpsocket.h:107
Returns the UDP transport protocol.
Reimplements
{#seterror-3}
setError
virtual override
virtual void setError(const icy::Error & err) override
Defined in src/net/include/icy/net/udpsocket.h:111
Sets the socket error and triggers close.
Parameters
errThe error to record.
Reimplements
{#error-8}
error
virtual const override
virtual const icy::Error & error() const override
Defined in src/net/include/icy/net/udpsocket.h:114
Returns the current socket error, if any.
Reimplements
{#closed-3}
closed
virtual const override
virtual bool closed() const override
Defined in src/net/include/icy/net/udpsocket.h:117
Returns true if the native socket handle is closed.
Reimplements
{#loop-5}
loop
virtual const override
virtual uv::Loop * loop() const override
Defined in src/net/include/icy/net/udpsocket.h:120
Returns the event loop associated with this socket.
Reimplements
{#onrecv-1}
onRecv
virtual
virtual void onRecv(const MutableBuffer & buf, const net::Address & address)
Defined in src/net/include/icy/net/udpsocket.h:125
Dispatches a received datagram to all socket adapters via onSocketRecv.
Parameters
Protected Attributes
| Return | Name | Description |
|---|---|---|
net::Address | _peer | |
Buffer | _buffer |
{#_peer}
_peer
net::Address _peer
Defined in src/net/include/icy/net/udpsocket.h:141
{#_buffer}
_buffer
Buffer _buffer
Defined in src/net/include/icy/net/udpsocket.h:142
Protected Methods
| Return | Name | Description |
|---|---|---|
void | init virtual override | Initializes the underlying socket context. |
void | reset virtual override | Resets the socket context for reuse. |
void | onError virtual override | Called by [setError()](#seterror-3) after the error state has been updated. |
void | onClose virtual override | Called by [close()](#close-16) after the context has been released. |
bool | recvStart virtual | |
bool | recvStop virtual |
{#init-6}
init
virtual override
virtual void init() override
Defined in src/net/include/icy/net/udpsocket.h:128
Initializes the underlying socket context.
Reimplements
{#reset-6}
reset
virtual override
virtual void reset() override
Defined in src/net/include/icy/net/udpsocket.h:129
Resets the socket context for reuse.
Reimplements
{#onerror-2}
onError
virtual override
virtual void onError(const icy::Error & error) override
Defined in src/net/include/icy/net/udpsocket.h:131
Called by [setError()](#seterror-3) after the error state has been updated.
Override to react to errors. The default implementation is a no-op.
Parameters
errorThe error that was set.
Reimplements
{#onclose-2}
onClose
virtual override
virtual void onClose() override
Defined in src/net/include/icy/net/udpsocket.h:132
Called by [close()](#close-16) after the context has been released.
Override to perform cleanup on handle closure. The default implementation is a no-op.
Reimplements
{#recvstart}
recvStart
virtual
virtual bool recvStart()
Defined in src/net/include/icy/net/udpsocket.h:134
{#recvstop}
recvStop
virtual
virtual bool recvStop()
Defined in src/net/include/icy/net/udpsocket.h:135
Public Types
| Name | Description |
|---|---|
Ptr | |
Vec |
{#ptr-10}
Ptr
using Ptr = std::shared_ptr< UDPSocket >
Defined in src/net/include/icy/net/udpsocket.h:32
{#vec-3}
Vec
using Vec = std::vector< Ptr >
Defined in src/net/include/icy/net/udpsocket.h:33
{#verificationerrordetails}
VerificationErrorDetails
#include <icy/net/sslmanager.h>
class VerificationErrorDetails
Defined in src/net/include/icy/net/sslmanager.h:134
A utility class for certificate error handling.
List of all members
| Name | Kind | Owner |
|---|---|---|
VerificationErrorDetails | function | Declared here |
~VerificationErrorDetails | function | Declared here |
certificate | function | Declared here |
errorDepth | function | Declared here |
errorNumber | function | Declared here |
errorMessage | function | Declared here |
setIgnoreError | function | Declared here |
getIgnoreError | function | Declared here |
_cert | variable | Declared here |
_errorDepth | variable | Declared here |
_errorNumber | variable | Declared here |
_errorMessage | variable | Declared here |
_ignoreError | variable | Declared here |
Public Methods
| Return | Name | Description |
|---|---|---|
VerificationErrorDetails | Creates the VerificationErrorDetails. _ignoreError is per default set to false. | |
~VerificationErrorDetails noexcept | Destroys the VerificationErrorDetails. | |
const crypto::X509Certificate & | certificate const inline | Returns the certificate that caused the error. |
int | errorDepth const inline | Returns the position of the certificate in the certificate chain. |
int | errorNumber const inline | Returns the id of the error. |
const std::string & | errorMessage const inline | Returns the textual presentation of the errorNumber. |
void | setIgnoreError inline | setIgnoreError to true, if a verification error is judged non-fatal by the user. |
bool | getIgnoreError const inline | returns the value of _ignoreError |
{#verificationerrordetails-1}
VerificationErrorDetails
VerificationErrorDetails(const crypto::X509Certificate & cert, int errDepth, int errNum, const std::string & errMsg)
Defined in src/net/include/icy/net/sslmanager.h:139
Creates the VerificationErrorDetails. _ignoreError is per default set to false.
{#verificationerrordetails-2}
~VerificationErrorDetails
noexcept
~VerificationErrorDetails() noexcept
Defined in src/net/include/icy/net/sslmanager.h:143
Destroys the VerificationErrorDetails.
{#certificate}
certificate
const inline
inline const crypto::X509Certificate & certificate() const
Defined in src/net/include/icy/net/sslmanager.h:146
Returns the certificate that caused the error.
{#errordepth}
errorDepth
const inline
inline int errorDepth() const
Defined in src/net/include/icy/net/sslmanager.h:149
Returns the position of the certificate in the certificate chain.
{#errornumber}
errorNumber
const inline
inline int errorNumber() const
Defined in src/net/include/icy/net/sslmanager.h:152
Returns the id of the error.
{#errormessage}
errorMessage
const inline
inline const std::string & errorMessage() const
Defined in src/net/include/icy/net/sslmanager.h:155
Returns the textual presentation of the errorNumber.
{#setignoreerror}
setIgnoreError
inline
inline void setIgnoreError(bool ignoreError)
Defined in src/net/include/icy/net/sslmanager.h:159
setIgnoreError to true, if a verification error is judged non-fatal by the user.
{#getignoreerror}
getIgnoreError
const inline
inline bool getIgnoreError() const
Defined in src/net/include/icy/net/sslmanager.h:162
returns the value of _ignoreError
Private Attributes
| Return | Name | Description |
|---|---|---|
crypto::X509Certificate | _cert | |
int | _errorDepth | |
int | _errorNumber | |
std::string | _errorMessage | |
bool | _ignoreError |
{#_cert}
_cert
crypto::X509Certificate _cert
Defined in src/net/include/icy/net/sslmanager.h:165
{#_errordepth}
_errorDepth
int _errorDepth
Defined in src/net/include/icy/net/sslmanager.h:166
{#_errornumber}
_errorNumber
int _errorNumber
Defined in src/net/include/icy/net/sslmanager.h:167
{#_errormessage}
_errorMessage
std::string _errorMessage
Defined in src/net/include/icy/net/sslmanager.h:168
{#_ignoreerror}
_ignoreError
bool _ignoreError
Defined in src/net/include/icy/net/sslmanager.h:169
{#packetinfo}
PacketInfo
#include <icy/net/socket.h>
struct PacketInfo
Defined in src/net/include/icy/net/socket.h:155
Inherits:
IPacketInfo
Provides information about packets emitted from a socket. See SocketPacket.
List of all members
| Name | Kind | Owner |
|---|---|---|
socket | variable | Declared here |
peerAddress | variable | Declared here |
PacketInfo | function | Declared here |
PacketInfo | function | Declared here |
clone | function | Declared here |
IPacketInfo | function | Inherited from IPacketInfo |
~IPacketInfo | function | Inherited from IPacketInfo |
clone | function | Inherited from IPacketInfo |
Inherited from IPacketInfo
| Kind | Name | Description |
|---|---|---|
function | IPacketInfo | Defaulted constructor. |
function | ~IPacketInfo virtual | Defaulted destructor. |
function | clone virtual const | Returns a heap-allocated deep copy of this info object. |
Public Attributes
| Return | Name | Description |
|---|---|---|
Socket::Ptr | socket | The source socket. |
Address | peerAddress | The originating peer address. For TCP this will always be connected address. |
{#socket}
socket
Socket::Ptr socket
Defined in src/net/include/icy/net/socket.h:158
The source socket.
{#peeraddress}
peerAddress
Address peerAddress
Defined in src/net/include/icy/net/socket.h:162
The originating peer address. For TCP this will always be connected address.
Public Methods
| Return | Name | Description |
|---|---|---|
PacketInfo inline | Constructs PacketInfo with the originating socket and peer address. | |
PacketInfo inline | Copy constructor. | |
std::unique_ptr< IPacketInfo > | clone virtual const inline | Returns a heap-allocated copy of this PacketInfo. |
{#packetinfo-1}
PacketInfo
inline
inline PacketInfo(const Socket::Ptr & socket, const Address & peerAddress)
Defined in src/net/include/icy/net/socket.h:167
Constructs PacketInfo with the originating socket and peer address.
Parameters
-
socketShared pointer to the socket that received the packet. -
peerAddressAddress of the remote peer that sent the packet.
{#packetinfo-2}
PacketInfo
inline
inline PacketInfo(const PacketInfo & r)
Defined in src/net/include/icy/net/socket.h:175
Copy constructor.
Parameters
rSource PacketInfo to copy from.
{#clone-5}
clone
virtual const inline
virtual inline std::unique_ptr< IPacketInfo > clone() const
Defined in src/net/include/icy/net/socket.h:182
Returns a heap-allocated copy of this PacketInfo.
Reimplements
{#dns}
dns
DNS utilities.
Functions
| Return | Name | Description |
|---|---|---|
auto | resolve inline | Resolves a hostname to a network address asynchronously. |
{#resolve-1}
resolve
inline
inline auto resolve(const std::string & host, int port, std::function< void(int, const net::Address &)> callback, uv::Loop * loop = uv::defaultLoop())
Resolves a hostname to a network address asynchronously.
The callback is invoked on the event loop thread when resolution completes. On failure, the callback receives a non-zero status and an empty Address.
Parameters
-
hostHostname or IP address string to resolve. -
portPort number to associate with the resolved address. -
callbackInvoked with (status, resolved Address); status is 0 on success. -
loopEvent loop to use; defaults to the default loop.
Returns
A request handle whose lifetime controls the in-flight DNS query.