net

May 15, 2026 ยท View on GitHub

{#netmodule}

net

TCP/SSL/UDP networking, socket adapters, DNS resolution.

Namespaces

NameDescription
netSocket transports, adapters, and address helpers.
dnsDNS utilities.

{#net}

net

Socket transports, adapters, and address helpers.

Classes

NameDescription
AddressRepresents an IPv4 or IPv6 socket address with host and port.
PacketSocketEmitterSocket adapter that emits received data as packets.
SocketBase socket implementation from which all sockets derive.
SocketAdapterAbstract adapter interface for socket send/receive chains.
SocketEmitterSocketAdapter that exposes socket events as signals.
SocketPacketDefault packet type emitted by sockets.
SSLAdapterManages the OpenSSL context and BIO buffers for an SSL socket connection.
SSLContextOpenSSL SSL_CTX wrapper for client and server TLS configuration.
SSLManagerSingleton that owns the default client/server TLS contexts and related callbacks.
SSLSessionCached SSL/TLS session wrapper used for client-side resumption.
SSLSocketSSL socket implementation.
TCPSocketTCP socket implementation.
TransactionRequest/response helper for packet types emitted from a socket.
UDPSocketUDP socket implementation.
VerificationErrorDetailsA utility class for certificate error handling.
PacketInfoProvides information about packets emitted from a socket. See SocketPacket.

Enumerations

NameDescription
TransportTypeTransport protocol identifier used to distinguish socket types at runtime.
SocketModeTransport mode for socket adapters and accepted connections.

{#transporttype}

TransportType

enum TransportType

Transport protocol identifier used to distinguish socket types at runtime.

ValueDescription
UDPUnreliable datagram protocol.
TCPReliable stream protocol.
SSLTCPTLS-encrypted TCP stream.

{#socketmode}

SocketMode

enum SocketMode

Transport mode for socket adapters and accepted connections.

ValueDescription
ServerSideServer-side adapter.
ClientSideClient-side adapter.

Functions

ReturnNameDescription
std::shared_ptr< SocketT >makeSocket inlineCreates a socket of type SocketT wrapped in a shared_ptr.
SSLContext::VerificationModeconvertVerificationMode inlineNon-case sensitive conversion of a string to a VerificationMode enum. If verMode is illegal an ArgumentException is thrown.
std::stringconvertCertificateError inlineConverts an SSL certificate handling error code into an error message.
std::stringgetLastError inlineReturns the last error from the error stack.
voidclearErrorStack inlineClears the error stack.
voidgetNetworkInterfaces inlinePopulates hosts with all local network interface addresses.
intgetServerSocketSendBufSizeReturns 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.
intgetServerSocketRecvBufSizeReturns 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.
intsetServerSocketSendBufSizeSets the send buffer size for a socket handle.
intsetServerSocketRecvBufSizeSets 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

  • loop Event 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

  • hosts Vector 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

  • T The libuv handle type (e.g. uv_tcp_t, uv_udp_t).

Parameters

  • handle The 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

  • T The libuv handle type (e.g. uv_tcp_t, uv_udp_t).

Parameters

  • handle The 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

  • T The libuv handle type (e.g. uv_tcp_t, uv_udp_t).

Parameters

  • handle The socket handle to configure.

  • size The 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

  • T The libuv handle type (e.g. uv_tcp_t, uv_udp_t).

Parameters

  • handle The socket handle to configure.

  • size The desired receive buffer size in bytes.

Returns

0 on success, or a libuv error code on failure.

Variables

ReturnNameDescription
intMAX_TCP_PACKET_SIZE constexprMaximum size of a single TCP receive buffer, in bytes.
intMAX_UDP_PACKET_SIZE constexprMaximum 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

NameKindOwner
operator<<friendDeclared here
AddressfunctionDeclared here
AddressfunctionDeclared here
AddressfunctionDeclared here
AddressfunctionDeclared here
AddressfunctionDeclared here
AddressfunctionDeclared here
~AddressfunctionDeclared here
operator=functionDeclared here
swapfunctionDeclared here
hostfunctionDeclared here
portfunctionDeclared here
lengthfunctionDeclared here
addrfunctionDeclared here
affunctionDeclared here
toStringfunctionDeclared here
familyfunctionDeclared here
validfunctionDeclared here
operator<functionDeclared here
operator==functionDeclared here
operator!=functionDeclared here
resolveServicefunctionDeclared here
validateIPfunctionDeclared here
initfunctionDeclared here
FamilyenumDeclared here
_basevariableDeclared here

Friends

NameDescription
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

ReturnNameDescription
AddressCreates a wildcard (all zero) IPv4 Address.
AddressCreates an Address from an IP address and a port number.
AddressCreates an Address by copying another one.
AddressCreates an Address from a native socket address.
AddressCreates an Address from an IP address and a service name or port number.
Address explicitCreates 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 noexceptDestroys the Address.
Address &operator=Assigns another Address.
voidswapSwaps the Address with another one.
std::stringhost constReturns the host IP address.
uint16_tport constReturns the port number.
socklen_tlength constReturns the length of the internal native socket address.
const struct sockaddr *addr constReturns a pointer to the internal native socket address.
intaf constReturns the address family (AF_INET or AF_INET6) of the address.
std::stringtoString constReturns a string representation of the address.
Address::Familyfamily constReturns the address family of the host's address.
boolvalid constReturns true when the port is set and the address is valid ie. not wildcard.
booloperator< constCompares two addresses for ordering (by family then port).
booloperator== constReturns true if the host and port of both addresses are equal.
booloperator!= constReturns 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

  • addr The 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

  • addr The 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

  • addr The address to compare against.

Public Static Methods

ReturnNameDescription
uint16_tresolveService staticResolves a service name or decimal port string to a port number.
boolvalidateIP staticReturns 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

  • service Service 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

  • address The string to validate.

Returns

true if the address parses as a valid IP address, false otherwise.

Protected Methods

ReturnNameDescription
voidinit

{#init-3}

init

void init(const std::string & host, uint16_t port)

Defined in src/net/include/icy/net/address.h:138

Public Types

NameDescription
FamilyPossible 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.

ValueDescription
IPv4
IPv6

Private Attributes

ReturnNameDescription
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

NameKindOwner
factoryvariableDeclared here
PacketSocketEmitterfunctionDeclared here
onSocketRecvfunctionDeclared here
onPacketfunctionDeclared here
ConnectvariableInherited from SocketEmitter
RecvvariableInherited from SocketEmitter
ErrorvariableInherited from SocketEmitter
ClosevariableInherited from SocketEmitter
implvariableInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
~SocketEmitterfunctionInherited from SocketEmitter
addReceiverfunctionInherited from SocketEmitter
removeReceiverfunctionInherited from SocketEmitter
swapfunctionInherited from SocketEmitter
asfunctionInherited from SocketEmitter
operator->functionInherited from SocketEmitter
onSocketConnectfunctionInherited from SocketEmitter
onSocketRecvfunctionInherited from SocketEmitter
onSocketErrorfunctionInherited from SocketEmitter
onSocketClosefunctionInherited from SocketEmitter
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from SocketEmitter

KindNameDescription
variableConnectSignals that the socket is connected.
variableRecvSignals when data is received by the socket.
variableErrorSignals that the socket is closed in error. This signal will be sent just before the Closed signal.
variableCloseSignals that the underlying socket is closed.
variableimplPointer to the underlying socket. Sent data will be proxied to this socket.
functionSocketEmitterCreates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver.
functionSocketEmitterCopy constructor; copies all signal connections and attaches to the same socket.
function~SocketEmitter virtual noexceptDestroys the SocketAdapter.
functionaddReceiver virtual overrideAttaches a SocketAdapter as a receiver; wires it to all four socket signals.
functionremoveReceiver virtual overrideDetaches a SocketAdapter from all four socket signals.
functionswap virtualReplaces the underlying socket with socket.
functionas inlineReturns the underlying socket cast to type T, or nullptr if the cast fails.
functionoperator-> const inlineReturns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer.
functiononSocketConnect virtual overrideForwards the connect event to chained adapters, then fires the Connect signal.
functiononSocketRecv virtual overrideForwards the recv event to chained adapters, then fires the Recv signal.
functiononSocketError virtual overrideForwards the error event to chained adapters, then fires the Error signal.
functiononSocketClose virtual overrideForwards the close event to chained adapters, then fires the Close signal.

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Attributes

ReturnNameDescription
PacketFactoryfactoryThe packet factory.

{#factory}

factory

PacketFactory factory

Defined in src/net/include/icy/net/packetsocket.h:59

The packet factory.

Public Methods

ReturnNameDescription
PacketSocketEmitterCreates the PacketSocketEmitter and attaches it to the given socket.
boolonSocketRecv virtual overrideParses raw received data into packets via the factory and forwards each parsed packet to onPacket(). Returns true if propagation should stop.
boolonPacket virtualProcess 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

  • socket Optional 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

  • socket The socket that received the data.

  • buffer The raw received data buffer.

  • peerAddress The 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: SocketAdapter Subclassed by: TCPSocket, UDPSocket

Base socket implementation from which all sockets derive.

List of all members

NameKindOwner
opaquevariableDeclared here
SocketfunctionDeclared here
SocketfunctionDeclared here
SocketfunctionDeclared here
connectfunctionDeclared here
connectfunctionDeclared here
bindfunctionDeclared here
listenfunctionDeclared here
shutdownfunctionDeclared here
sendOwnedfunctionDeclared here
sendOwnedfunctionDeclared here
closefunctionDeclared here
addressfunctionDeclared here
peerAddressfunctionDeclared here
transportfunctionDeclared here
setErrorfunctionDeclared here
errorfunctionDeclared here
closedfunctionDeclared here
loopfunctionDeclared here
_afvariableDeclared here
initfunctionDeclared here
resetfunctionDeclared here
PtrtypedefDeclared here
VectypedefDeclared here
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Attributes

ReturnNameDescription
std::anyopaqueOptional 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

ReturnNameDescription
SocketDefaulted constructor.
SocketDeleted constructor.
SocketDeleted constructor.
voidconnect virtualConnects to the given peer IP address.
voidconnect virtualResolves and connects to the given host address.
voidbind virtualBind a local address to the socket. The address may be IPv4 or IPv6 (if supported).
voidlisten virtual inlineListens the socket on the given address.
boolshutdown virtual inline nodiscardSends the shutdown packet which should result is socket closure via callback.
ssize_tsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
ssize_tsendOwned virtual nodiscard
voidclose virtualCloses the underlying socket.
Addressaddress virtual constThe locally bound address.
AddresspeerAddress virtual constThe connected peer address.
net::TransportTypetransport virtual constThe transport protocol: TCP, UDP or SSLTCP.
voidsetError virtualSets the socket error.
const icy::Error &error virtual constReturn the socket error if any.
boolclosed virtual constReturns true if the native socket handle is closed.
uv::Loop *loop virtual constReturns 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

ReturnNameDescription
int_af

{#_af}

_af

int _af {AF_UNSPEC}

Defined in src/net/include/icy/net/socket.h:144

Protected Methods

ReturnNameDescription
voidinit virtualInitializes the underlying socket context.
voidreset virtualResets 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

NameDescription
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

NameKindOwner
priorityvariableDeclared here
SocketAdapterfunctionDeclared here
~SocketAdapterfunctionDeclared here
sendfunctionDeclared here
sendfunctionDeclared here
sendOwnedfunctionDeclared here
sendOwnedfunctionDeclared here
sendPacketfunctionDeclared here
sendPacketfunctionDeclared here
sendPacketfunctionDeclared here
setSenderfunctionDeclared here
senderfunctionDeclared here
addReceiverfunctionDeclared here
removeReceiverfunctionDeclared here
hasReceiverfunctionDeclared here
receiversfunctionDeclared here
onSocketConnectfunctionDeclared here
onSocketRecvfunctionDeclared here
onSocketErrorfunctionDeclared here
onSocketClosefunctionDeclared here
_sendervariableDeclared here
_receiversvariableDeclared here
_dirtyvariableDeclared here
cleanupReceiversfunctionDeclared here

Public Attributes

ReturnNameDescription
intpriorityThe 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

ReturnNameDescription
SocketAdapterCreates the SocketAdapter.
~SocketAdapter virtual noexceptDestroys the SocketAdapter.
ssize_tsend virtual nodiscardSends 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_tsend virtual nodiscard
ssize_tsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
ssize_tsendOwned virtual nodiscard
ssize_tsendPacket virtualSends 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_tsendPacket virtual
voidsendPacket virtualSends 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.
voidsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
SocketAdapter *senderReturns the output SocketAdapter pointer.
voidaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
voidremoveReceiver virtualRemove the given receiver.
boolhasReceiver virtualReturns true if the given receiver is connected.
std::vector< SocketAdapter * >receiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
boolonSocketConnect virtualCalled 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.
boolonSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
boolonSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
boolonSocketClose virtualCalled 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

  • socket The 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

  • socket The socket that received data.

  • buffer The received data buffer.

  • peerAddress Address 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

  • socket The socket that encountered the error.

  • error Error 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

  • socket The socket that was closed.

Returns

true to stop propagation to subsequent receivers.

Reimplemented by

Protected Attributes

ReturnNameDescription
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

ReturnNameDescription
voidcleanupReceivers 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

NameKindOwner
ptrvariableDeclared here
alivevariableDeclared here

Public Attributes

ReturnNameDescription
SocketAdapter *ptr
boolalive

{#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: SocketAdapter Subclassed 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

NameKindOwner
ConnectvariableDeclared here
RecvvariableDeclared here
ErrorvariableDeclared here
ClosevariableDeclared here
implvariableDeclared here
SocketEmitterfunctionDeclared here
SocketEmitterfunctionDeclared here
~SocketEmitterfunctionDeclared here
addReceiverfunctionDeclared here
removeReceiverfunctionDeclared here
swapfunctionDeclared here
asfunctionDeclared here
operator->functionDeclared here
onSocketConnectfunctionDeclared here
onSocketRecvfunctionDeclared here
onSocketErrorfunctionDeclared here
onSocketClosefunctionDeclared here
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Attributes

ReturnNameDescription
LocalSignal< bool(Socket &)>ConnectSignals that the socket is connected.
LocalSignal< bool(Socket &, const MutableBuffer &, const Address &)>RecvSignals when data is received by the socket.
LocalSignal< bool(Socket &, const icy::Error &)>ErrorSignals that the socket is closed in error. This signal will be sent just before the Closed signal.
LocalSignal< bool(Socket &)>CloseSignals that the underlying socket is closed.
Socket::PtrimplPointer 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

ReturnNameDescription
SocketEmitterCreates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver.
SocketEmitterCopy constructor; copies all signal connections and attaches to the same socket.
~SocketEmitter virtual noexceptDestroys the SocketAdapter.
voidaddReceiver virtual overrideAttaches a SocketAdapter as a receiver; wires it to all four socket signals.
voidremoveReceiver virtual overrideDetaches a SocketAdapter from all four socket signals.
voidswap virtualReplaces the underlying socket with socket.
T *as inlineReturns the underlying socket cast to type T, or nullptr if the cast fails.
Socket *operator-> const inlineReturns 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

  • socket Optional 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


{#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

  • adapter The 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

  • adapter The 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

  • socket The 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

  • T Derived 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

ReturnNameDescription
boolonSocketConnect virtual overrideForwards the connect event to chained adapters, then fires the Connect signal.
boolonSocketRecv virtual overrideForwards the recv event to chained adapters, then fires the Recv signal.
boolonSocketError virtual overrideForwards the error event to chained adapters, then fires the Error signal.
boolonSocketClose virtual overrideForwards 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

NameKindOwner
SocketPacketfunctionDeclared here
SocketPacketfunctionDeclared here
packetInfofunctionDeclared here
printfunctionDeclared here
clonefunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
classNamefunctionDeclared here
_datavariableInherited from RawPacket
_sizevariableInherited from RawPacket
_ownedvariableInherited from RawPacket
RawPacketfunctionInherited from RawPacket
RawPacketfunctionInherited from RawPacket
RawPacketfunctionInherited from RawPacket
~RawPacketfunctionInherited from RawPacket
clonefunctionInherited from RawPacket
copyDatafunctionInherited from RawPacket
readfunctionInherited from RawPacket
writefunctionInherited from RawPacket
datafunctionInherited from RawPacket
sizefunctionInherited from RawPacket
classNamefunctionInherited from RawPacket
ownsBufferfunctionInherited from RawPacket
opaquevariableInherited from IPacket
infovariableInherited from IPacket
flagsvariableInherited from IPacket
IPacketfunctionInherited from IPacket
IPacketfunctionInherited from IPacket
operator=functionInherited from IPacket
clonefunctionInherited from IPacket
~IPacketfunctionInherited from IPacket
readfunctionInherited from IPacket
writefunctionInherited from IPacket
sizefunctionInherited from IPacket
hasDatafunctionInherited from IPacket
datafunctionInherited from IPacket
constDatafunctionInherited from IPacket
classNamefunctionInherited from IPacket
printfunctionInherited from IPacket
operator<<friendInherited from IPacket

Inherited from RawPacket

KindNameDescription
variable_data
variable_size
variable_owned
functionRawPacket inlineConstruct with borrowed (non-owning) buffer.
functionRawPacket inlineConstruct with const data (copied, owning).
functionRawPacket inlineCopy constructor (always copies data).
function~RawPacket virtualDefaulted destructor.
functionclone virtual const inline override
functioncopyData virtual inlineCopies data into an internally owned buffer, replacing any prior content.
functionread virtual inline overrideReads from the buffer by copying its contents into an owned buffer.
functionwrite virtual const inline overrideAppends the packet data to the given output buffer.
functiondata virtual const inline override
functionsize virtual const inline override
functionclassName virtual const inline overrideReturns the class name of this packet type for logging and diagnostics.
functionownsBuffer const inline

Inherited from IPacket

KindNameDescription
variableopaqueOptional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime.
variableinfoOptional extra information about the packet.
variableflagsProvides basic information about the packet.
functionIPacket inline
functionIPacket inlineCopy constructor; clones the info object if present.
functionoperator= inlineCopy assignment; clones the info object if present.
functionclone virtual constReturns a heap-allocated deep copy of this packet.
function~IPacket virtualDefaulted destructor.
functionread virtualRead/parse to the packet from the given input buffer. The number of bytes read is returned.
functionwrite virtual constCopy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer.
functionsize virtual const inlineThe size of the packet in bytes.
functionhasData virtual const inlineReturns true if the packet has a non-null data pointer.
functiondata virtual const inlineThe packet data pointer for buffered packets.
functionconstData virtual const inlineThe const packet data pointer for buffered packets.
functionclassName virtual constReturns the class name of this packet type for logging and diagnostics.
functionprint virtual const inlinePrints a human-readable representation to the given stream.
friendoperator<< inlineStream insertion operator; delegates to print().

Public Methods

ReturnNameDescription
SocketPacket inlineConstructs a SocketPacket wrapping the received buffer.
SocketPacket inlineCopy constructor; shares the underlying buffer reference.
PacketInfo *packetInfo const inlineReturns the PacketInfo for this socket packet.
voidprint virtual const inlinePrints a one-line description of the packet to os.
std::unique_ptr< IPacket >clone virtual const inlineReturns a heap-allocated copy of this SocketPacket.
ssize_tread virtual inlineNot supported; always throws std::logic_error.
voidwrite virtual const inlineAppends 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

  • socket Shared pointer to the receiving socket.

  • buffer View of the raw received bytes.

  • peerAddress Address 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


{#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}

print

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

  • os Output 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

  • buf Destination 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

NameKindOwner
SSLSocketfriendDeclared here
SSLAdapterfunctionDeclared here
SSLAdapterfunctionDeclared here
SSLAdapterfunctionDeclared here
initClientfunctionDeclared here
initServerfunctionDeclared here
initializedfunctionDeclared here
readyfunctionDeclared here
handshakefunctionDeclared here
availablefunctionDeclared here
shutdownfunctionDeclared here
flushfunctionDeclared here
setHostnamefunctionDeclared here
addIncomingDatafunctionDeclared here
addOutgoingDatafunctionDeclared here
addOutgoingDatafunctionDeclared here
addOutgoingDatafunctionDeclared here
_socketvariableDeclared here
_sslvariableDeclared here
_readBIOvariableDeclared here
_writeBIOvariableDeclared here
_bufferOutvariableDeclared here
_hostnamevariableDeclared here
handleErrorfunctionDeclared here
flushReadBIOfunctionDeclared here
flushWriteBIOfunctionDeclared here

Friends

NameDescription
net::SSLSocket

{#net-sslsocket}

net::SSLSocket

friend class net::SSLSocket

Defined in src/net/include/icy/net/ssladapter.h:107

Public Methods

ReturnNameDescription
SSLAdapterConstructs the SSLAdapter and associates it with the given socket. The socket pointer must remain valid for the lifetime of this adapter.
SSLAdapterDeleted constructor.
SSLAdapterDeleted constructor.
voidinitClientInitializes the SSL context as a client.
voidinitServerInitializes the SSL context as a server.
boolinitialized constReturns true when SSL context has been initialized.
boolready constReturns true when the handshake is complete.
voidhandshakeStart/continue the SSL handshake process.
intavailable constReturns the number of bytes available in the SSL buffer for immediate reading.
voidshutdownIssues an orderly SSL shutdown.
voidflushFlushes the SSL read/write buffers.
voidsetHostnameSet the expected peer hostname for certificate verification. Must be called before initClient() to enable hostname verification.
voidaddIncomingDataFeeds 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().
voidaddOutgoingDataQueues plaintext data for encryption and transmission.
voidaddOutgoingDataQueues plaintext data for encryption and transmission.
voidaddOutgoingDataMoves 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

  • socket The 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

  • data Pointer to the encrypted bytes.

  • len Number 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

  • data String 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

  • data Pointer to the plaintext bytes.

  • len Number 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

ReturnNameDescription
net::SSLSocket *_socket
SSL *_ssl
BIO *_readBIOThe incoming buffer we write encrypted SSL data into.
BIO *_writeBIOThe outgoing buffer we write to the socket.
std::vector< char >_bufferOutThe outgoing payload to be encrypted and sent.
std::string_hostnameExpected 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

ReturnNameDescription
voidhandleError
voidflushReadBIO
voidflushWriteBIO

{#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

NameKindOwner
SSLContextfunctionDeclared here
SSLContextfunctionDeclared here
~SSLContextfunctionDeclared here
useCertificatefunctionDeclared here
addChainCertificatefunctionDeclared here
addVerificationCertificatefunctionDeclared here
sslContextfunctionDeclared here
usagefunctionDeclared here
isForServerUsefunctionDeclared here
verificationModefunctionDeclared here
enableSessionCachefunctionDeclared here
enableSessionCachefunctionDeclared here
sessionCacheEnabledfunctionDeclared here
setSessionCacheSizefunctionDeclared here
getSessionCacheSizefunctionDeclared here
setSessionTimeoutfunctionDeclared here
getSessionTimeoutfunctionDeclared here
flushSessionCachefunctionDeclared here
disableStatelessSessionResumptionfunctionDeclared here
setALPNProtocolsfunctionDeclared here
SSLContextfunctionDeclared here
SSLContextfunctionDeclared here
enableSNIfunctionDeclared here
UsageenumDeclared here
VerificationModeenumDeclared here
PtrtypedefDeclared here
_usagevariableDeclared here
_modevariableDeclared here
_sslContextvariableDeclared here
_alpnWirevariableDeclared here
createSSLContextfunctionDeclared here

Public Methods

ReturnNameDescription
SSLContextCreates a Context.
SSLContextCreates a Context.
~SSLContext noexceptDestroys the Context.
voiduseCertificateSets the certificate to be used by the Context.
voidaddChainCertificateAdds a certificate for certificate chain validation.
voidaddVerificationCertificateSets the private key to be used by the Context.
SSL_CTX *sslContext const inlineReturns the underlying OpenSSL SSL Context object.
Usageusage const inlineReturns whether the context is for use by a client or by a server and whether TLSv1 is required.
boolisForServerUse const inlineReturns true if the context is for use by a server.
SSLContext::VerificationModeverificationMode const inlineReturns the verification mode.
voidenableSessionCacheEnable 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.
voidenableSessionCacheEnables 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.
boolsessionCacheEnabled constReturns true if the session cache is enabled.
voidsetSessionCacheSizeSets 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_tgetSessionCacheSize constReturns the current maximum size of the server session cache.
voidsetSessionTimeoutSets 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.
longgetSessionTimeout constReturns the timeout (in seconds) of cached sessions on the server.
voidflushSessionCacheFlushes the SSL session cache on the server.
voiddisableStatelessSessionResumptionNewer versions of OpenSSL support RFC 4507 tickets for stateless session resumption.
voidsetALPNProtocolsSet the ALPN protocols for negotiation. Protocols should be in preference order. Example: {"h2", "http/1.1"}
SSLContextDeleted constructor.
SSLContextDeleted 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

ReturnNameDescription
voidenableSNI staticEnable 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

NameDescription
Usage
VerificationMode
Ptr

{#usage-1}

Usage

enum Usage

Defined in src/net/include/icy/net/sslcontext.h:49

ValueDescription
CLIENT_USEContext is used by a client.
SERVER_USEContext is used by a server.
TLSV1_CLIENT_USEContext is used by a client requiring TLSv1.
TLSV1_SERVER_USEContext is used by a server requiring TLSv2.

{#verificationmode-1}

VerificationMode

enum VerificationMode

Defined in src/net/include/icy/net/sslcontext.h:57

ValueDescription
VERIFY_NONEServer: The server will not send a client certificate request to the client, so the client will not send a certificate.
VERIFY_RELAXEDServer: 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_STRICTServer: If the client did not return a certificate, the TLS/SSL handshake is immediately terminated with a handshake failure alert.
VERIFY_ONCEServer: 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

ReturnNameDescription
Usage_usage
VerificationMode_mode
SSL_CTX *_sslContext
std::vector< unsigned char >_alpnWireWire-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

ReturnNameDescription
voidcreateSSLContextCreate 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

NameKindOwner
Singleton< SSLManager >friendDeclared here
SSLContextfriendDeclared here
ServerVerificationErrorvariableDeclared here
ClientVerificationErrorvariableDeclared here
PrivateKeyPassphraseRequiredvariableDeclared here
initializeServerfunctionDeclared here
initializeClientfunctionDeclared here
defaultServerContextfunctionDeclared here
defaultClientContextfunctionDeclared here
shutdownfunctionDeclared here
instancefunctionDeclared here
destroyfunctionDeclared here
initNoVerifyClientfunctionDeclared here
initNoVerifyServerfunctionDeclared here
_defaultServerContextvariableDeclared here
_defaultClientContextvariableDeclared here
_mutexvariableDeclared here
SSLManagerfunctionDeclared here
~SSLManagerfunctionDeclared here
SSLManagerfunctionDeclared here
SSLManagerfunctionDeclared here
verifyCallbackfunctionDeclared here

Friends

NameDescription
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

ReturnNameDescription
ThreadSignal< void(VerificationErrorDetails &)>ServerVerificationErrorFired whenever a certificate verification error is detected by the server during a handshake.
ThreadSignal< void(VerificationErrorDetails &)>ClientVerificationErrorFired whenever a certificate verification error is detected by the client during a handshake.
ThreadSignal< void(std::string &)>PrivateKeyPassphraseRequiredFired 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

ReturnNameDescription
voidinitializeServerInitializes the server side of the SSLManager server-side SSLContext.
voidinitializeClientInitializes the client side of the SSLManager with a default client-side SSLContext.
SSLContext::PtrdefaultServerContextReturns the default context used by the server if initialized.
SSLContext::PtrdefaultClientContextReturns the default context used by the client if initialized.
voidshutdownShuts 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

ReturnNameDescription
SSLManager &instance staticReturns the instance of the SSLManager singleton.
voiddestroy staticShuts down and destroys the SSLManager singleton instance.
voidinitNoVerifyClient staticInitializes a default no-verify client context that's useful for testing.
voidinitNoVerifyServer staticInitializes 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

ReturnNameDescription
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

ReturnNameDescription
SSLManagerCreates the SSLManager.
~SSLManager noexceptDestroys the SSLManager.
SSLManagerDeleted constructor.
SSLManagerDeleted 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

ReturnNameDescription
intverifyCallback staticThe 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

NameKindOwner
sslSessionfunctionDeclared here
SSLSessionfunctionDeclared here
~SSLSessionfunctionDeclared here
SSLSessionfunctionDeclared here
SSLSessionfunctionDeclared here
SSLSessionfunctionDeclared here
_ptrvariableDeclared here
PtrtypedefDeclared here

Public Methods

ReturnNameDescription
SSL_SESSION *sslSession constReturns the stored OpenSSL SSL_SESSION object.
SSLSessionCreates a new SSLSession wrapping the given OpenSSL session object.
~SSLSession noexceptDestroys the Session.
SSLSessionConstructs an empty SSLSession with a null session pointer.
SSLSessionDeleted constructor.
SSLSessionDeleted 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

  • ptr The 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

ReturnNameDescription
SSL_SESSION *_ptr

{#_ptr}

_ptr

SSL_SESSION * _ptr

Defined in src/net/include/icy/net/sslsession.h:61

Public Types

NameDescription
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

NameKindOwner
SSLAdapterfriendDeclared here
SSLSocketfunctionDeclared here
SSLSocketfunctionDeclared here
SSLSocketfunctionDeclared here
connectfunctionDeclared here
connectfunctionDeclared here
bindfunctionDeclared here
listenfunctionDeclared here
shutdownfunctionDeclared here
closefunctionDeclared here
sendfunctionDeclared here
sendOwnedfunctionDeclared here
sendfunctionDeclared here
sendOwnedfunctionDeclared here
setHostnamefunctionDeclared here
useContextfunctionDeclared here
contextfunctionDeclared here
useSessionfunctionDeclared here
currentSessionfunctionDeclared here
sessionWasReusedfunctionDeclared here
availablefunctionDeclared here
peerCertificatefunctionDeclared here
transportfunctionDeclared here
acceptConnectionfunctionDeclared here
onConnectfunctionDeclared here
onReadfunctionDeclared here
_sslContextvariableDeclared here
_sslSessionvariableDeclared here
_sslAdaptervariableDeclared here
PtrtypedefDeclared here
VectypedefDeclared here
AcceptConnectionvariableInherited from TCPSocket
TCPSocketfunctionInherited from TCPSocket
TCPSocketfunctionInherited from TCPSocket
TCPSocketfunctionInherited from TCPSocket
shutdownfunctionInherited from TCPSocket
closefunctionInherited from TCPSocket
connectfunctionInherited from TCPSocket
connectfunctionInherited from TCPSocket
sendfunctionInherited from TCPSocket
sendOwnedfunctionInherited from TCPSocket
sendfunctionInherited from TCPSocket
sendOwnedfunctionInherited from TCPSocket
bindfunctionInherited from TCPSocket
listenfunctionInherited from TCPSocket
acceptConnectionfunctionInherited from TCPSocket
setReusePortfunctionInherited from TCPSocket
setNoDelayfunctionInherited from TCPSocket
setKeepAlivefunctionInherited from TCPSocket
setSimultaneousAcceptsfunctionInherited from TCPSocket
setModefunctionInherited from TCPSocket
modefunctionInherited from TCPSocket
setErrorfunctionInherited from TCPSocket
errorfunctionInherited from TCPSocket
closedfunctionInherited from TCPSocket
addressfunctionInherited from TCPSocket
peerAddressfunctionInherited from TCPSocket
transportfunctionInherited from TCPSocket
loopfunctionInherited from TCPSocket
onConnectfunctionInherited from TCPSocket
onReadfunctionInherited from TCPSocket
onRecvfunctionInherited from TCPSocket
onErrorfunctionInherited from TCPSocket
onClosefunctionInherited from TCPSocket
_modevariableInherited from TCPSocket
_peerAddressvariableInherited from TCPSocket
initfunctionInherited from TCPSocket
resetfunctionInherited from TCPSocket
PtrtypedefInherited from TCPSocket
VectypedefInherited from TCPSocket
HandletypedefInherited from Stream
ReadvariableInherited from Stream
_buffervariableInherited from Stream
_startedvariableInherited from Stream
_highWaterMarkvariableInherited from Stream
_writeReqFreevariableInherited from Stream
_ownedWriteReqFreevariableInherited from Stream
StreamfunctionInherited from Stream
~StreamfunctionInherited from Stream
closefunctionInherited from Stream
shutdownfunctionInherited from Stream
writefunctionInherited from Stream
writeOwnedfunctionInherited from Stream
setHighWaterMarkfunctionInherited from Stream
writefunctionInherited from Stream
streamfunctionInherited from Stream
readStartfunctionInherited from Stream
readStopfunctionInherited from Stream
onReadfunctionInherited from Stream
allocWriteReqfunctionInherited from Stream
freeWriteReqfunctionInherited from Stream
allocOwnedWriteReqfunctionInherited from Stream
freeOwnedWriteReqfunctionInherited from Stream
canQueueWritefunctionInherited from Stream
handleReadfunctionInherited from Stream
allocReadBufferfunctionInherited from Stream
HandlefunctionInherited from Handle
initfunctionInherited from Handle
invokefunctionInherited from Handle
invokeOrThrowfunctionInherited from Handle
closefunctionInherited from Handle
reffunctionInherited from Handle
unreffunctionInherited from Handle
initializedfunctionInherited from Handle
activefunctionInherited from Handle
closingfunctionInherited from Handle
closedfunctionInherited from Handle
errorfunctionInherited from Handle
setErrorfunctionInherited from Handle
setUVErrorfunctionInherited from Handle
setAndThrowErrorfunctionInherited from Handle
throwLastErrorfunctionInherited from Handle
loopfunctionInherited from Handle
resetfunctionInherited from Handle
getfunctionInherited from Handle
tidfunctionInherited from Handle
contextfunctionInherited from Handle
setCloseCleanupfunctionInherited from Handle
clearCloseCleanupfunctionInherited from Handle
assertThreadfunctionInherited from Handle
_loopvariableInherited from Handle
_contextvariableInherited from Handle
_tidvariableInherited from Handle
_errorvariableInherited from Handle
onErrorfunctionInherited from Handle
onClosefunctionInherited from Handle
HandlefunctionInherited from Handle
HandlefunctionInherited from Handle
TypetypedefInherited from Handle
opaquevariableInherited from Socket
SocketfunctionInherited from Socket
SocketfunctionInherited from Socket
SocketfunctionInherited from Socket
connectfunctionInherited from Socket
connectfunctionInherited from Socket
bindfunctionInherited from Socket
listenfunctionInherited from Socket
shutdownfunctionInherited from Socket
sendOwnedfunctionInherited from Socket
sendOwnedfunctionInherited from Socket
closefunctionInherited from Socket
addressfunctionInherited from Socket
peerAddressfunctionInherited from Socket
transportfunctionInherited from Socket
setErrorfunctionInherited from Socket
errorfunctionInherited from Socket
closedfunctionInherited from Socket
loopfunctionInherited from Socket
_afvariableInherited from Socket
initfunctionInherited from Socket
resetfunctionInherited from Socket
PtrtypedefInherited from Socket
VectypedefInherited from Socket
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from TCPSocket

KindNameDescription
variableAcceptConnectionFired when a new client connection is accepted; carries a shared_ptr to the new socket.
functionTCPSocketConstructs the TCPSocket and initializes the underlying libuv handle.
functionTCPSocketDeleted constructor.
functionTCPSocketDeleted constructor.
functionshutdown virtual nodiscard overrideSends a TCP shutdown request; the socket closes after the peer acknowledges.
functionclose virtual overrideCloses the socket immediately, releasing all associated resources.
functionconnect virtual overrideConnects to peerAddress using a libuv connect request. On success, calls onConnect(); on failure, calls setUVError().
functionconnect virtual overrideResolves host via DNS (or maps "localhost"), then connects.
functionsend virtual nodiscard overrideWrites len bytes to the connected peer.
functionsendOwned virtual nodiscard overrideSends an owned payload buffer to the connected peer.
functionsend virtual nodiscard overrideWrites len bytes; peerAddress is ignored for TCP (connected stream).
functionsendOwned virtual nodiscard override
functionbind virtual overrideBinds the socket to address. Resets and reinitializes the handle if the address family changes.
functionlisten virtual overrideStarts listening for incoming connections with the given backlog.
functionacceptConnection virtualAccepts the next pending client connection and fires AcceptConnection.
functionsetReusePort nodiscardEnables 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.
functionsetNoDelay nodiscardEnables or disables TCP_NODELAY (Nagle's algorithm).
functionsetKeepAlive nodiscardEnables or disables TCP keep-alive probes.
functionsetSimultaneousAccepts nodiscardEnables or disables simultaneous accepts on Windows. No-op and returns false on non-Windows platforms.
functionsetModeSets the socket mode (ServerSide or ClientSide).
functionmode constReturns the current socket mode.
functionsetError virtual overrideSets the socket error; ignores the call if an error is already recorded. Setting an error causes the socket to close.
functionerror virtual const overrideReturns the current socket error, if any.
functionclosed virtual const overrideReturns true if the native socket handle is closed.
functionaddress virtual const overrideReturns the IP address and port number of the socket. A wildcard address is returned if the socket is not connected.
functionpeerAddress virtual const overrideReturns the IP address and port number of the peer socket. A wildcard address is returned if the socket is not connected.
functiontransport virtual const overrideReturns the TCP transport protocol.
functionloop virtual const overrideReturns the event loop associated with this socket.
functiononConnect virtualCalled by the stream layer when the TCP connection is established.
functiononRead virtual overrideCalled by the stream layer with raw received bytes; wraps them in a MutableBuffer.
functiononRecv virtualDispatches a received buffer to all socket adapters via onSocketRecv.
functiononError virtual overrideDispatches the error to adapters and closes the socket.
functiononClose virtual overrideDispatches the close event to all socket adapters.
variable_mode
variable_peerAddressCached peer address (avoids syscall per recv).
functioninit virtual overrideInitializes the underlying socket context.
functionreset virtual overrideResets the socket context for reuse.
typedefPtr
typedefVec

Inherited from Stream

KindNameDescription
typedefHandle
variableReadEmitted when data has been received from the peer.
variable_buffer
variable_started
variable_highWaterMark16MB default write queue limit
variable_writeReqFreeFreelist for write requests.
variable_ownedWriteReqFreeFreelist for owned write requests.
functionStream inlineConstruct the stream bound to loop with a 64 KiB read buffer.
function~Stream virtual inlineDestroy the stream, stopping reads and freeing pooled write requests.
functionclose virtual inline overrideCloses and resets the stream handle. This will close the active socket/pipe and destroy the handle.
functionshutdown inlineSend a TCP/pipe shutdown request to the connected peer.
functionwrite inlineWrite len bytes from data to the stream.
functionwriteOwned inlineWrite an owned payload buffer to the stream.
functionsetHighWaterMark inlineSet the high water mark for the write queue (default 16MB). When the write queue exceeds this size, write() returns false.
functionwrite inlineWrite len bytes from data together with a stream handle over an IPC pipe (uses uv_write2).
functionstream inlineReturn the underlying uv_stream_t pointer cast from the native handle.
functionreadStart virtual inlineBegin reading from the stream by registering libuv read callbacks.
functionreadStop virtual inlineStop reading from the stream.
functiononRead virtual inlineCalled by [handleRead](base.md#classicy_1_1Stream_1ac74fea672c0d281f2a4f51bee6943b10) when len bytes of data arrive.
functionallocWriteReq inlineReturn a uv_write_t from the freelist, or allocate a new one if the pool is empty.
functionfreeWriteReq inlineReturn req to the freelist, or delete it if the pool is at capacity.
functionallocOwnedWriteReq inline
functionfreeOwnedWriteReq inline
functioncanQueueWrite inline
functionhandleRead static inlineUV callbacks.
functionallocReadBuffer static inlinelibuv allocate-buffer callback. Provides the stream's internal buffer, growing it if libuv requests more space than the current allocation.

Inherited from Handle

KindNameDescription
functionHandle inlineConstruct the handle bound to the given event loop.
functioninit inlineInitialize the underlying libuv handle by calling f with the loop, the raw handle pointer, and any additional args.
functioninvoke inlineInvoke a libuv function f with args on the initialized handle.
functioninvokeOrThrow inlineInvoke a libuv function f with args, throwing on failure.
functionclose virtual inlineClose and destroy the handle.
functionref inlineRe-reference the handle with the event loop after a previous [unref()](uv.md#unref).
functionunref inlineUnreference the handle from the event loop.
functioninitialized const inlineReturn true if the handle has been successfully initialized via [init()](uv.md#init-2).
functionactive virtual const inlineReturn true when the handle is active (libuv uv_is_active).
functionclosing virtual const inlineReturn true if uv_close has been called and the handle is awaiting its close callback (libuv uv_is_closing).
functionclosed virtual const inlineReturn true if the handle has been fully closed (context released).
functionerror const inlineReturn the last error set on this handle, or a default-constructed [Error](base.md#error) if no error has occurred.
functionsetError virtual inlineSet the error state and invoke [onError()](uv.md#onerror).
functionsetUVError inlineTranslate a libuv error code into an [Error](base.md#error) and call [setError()](uv.md#seterror).
functionsetAndThrowError inlineSet the error state from a libuv error code and throw a std::runtime_error.
functionthrowLastError inlineThrow a std::runtime_error if the handle currently holds an error.
functionloop const inlineReturn the event loop this handle is bound to.
functionreset inlineClose 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).
functionget const inlineReturn the raw libuv handle pointer cast to [Handle](uv.md#handle-2).
functiontid const inlineReturn the ID of the thread that constructed this handle.
functioncontext const inlineReturn the raw [Context](uv.md#context-1) that owns the libuv handle memory.
functionsetCloseCleanup inline
functionclearCloseCleanup inline
functionassertThread const inlineThrow std::logic_error if called from any thread other than the thread that constructed this handle.
variable_loop
variable_context
variable_tid
variable_error
functiononError virtual inlineCalled by [setError()](uv.md#seterror) after the error state has been updated.
functiononClose virtual inlineCalled by [close()](uv.md#close-11) after the context has been released.
functionHandleNonCopyable and NonMovable.
functionHandleDeleted constructor.
typedefTypeDefine the native handle type.

Inherited from Socket

KindNameDescription
variableopaqueOptional client data.
functionSocketDefaulted constructor.
functionSocketDeleted constructor.
functionSocketDeleted constructor.
functionconnect virtualConnects to the given peer IP address.
functionconnect virtualResolves and connects to the given host address.
functionbind virtualBind a local address to the socket. The address may be IPv4 or IPv6 (if supported).
functionlisten virtual inlineListens the socket on the given address.
functionshutdown virtual inline nodiscardSends the shutdown packet which should result is socket closure via callback.
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionclose virtualCloses the underlying socket.
functionaddress virtual constThe locally bound address.
functionpeerAddress virtual constThe connected peer address.
functiontransport virtual constThe transport protocol: TCP, UDP or SSLTCP.
functionsetError virtualSets the socket error.
functionerror virtual constReturn the socket error if any.
functionclosed virtual constReturns true if the native socket handle is closed.
functionloop virtual constReturns the socket event loop.
variable_af
functioninit virtualInitializes the underlying socket context.
functionreset virtualResets the socket context for reuse.
typedefPtr
typedefVec

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Friends

NameDescription
net::SSLAdapter

{#net-ssladapter}

net::SSLAdapter

friend class net::SSLAdapter

Defined in src/net/include/icy/net/sslsocket.h:169

Public Methods

ReturnNameDescription
SSLSocketConstructs an SSLSocket that acquires its context from SSLManager on first use.
SSLSocketConstructs an SSLSocket with an explicit SSL context.
SSLSocketConstructs an SSLSocket with an explicit context and a prior session for resumption.
voidconnect virtual overrideInitialize the SSLSocket with the given SSLContext.
voidconnect virtual overrideResolves host and initiates a secure connection.
voidbind virtual overrideBinds the socket to address for server-side use. Throws std::logic_error if the context is not a server context.
voidlisten virtual overrideStarts listening for incoming connections. Throws std::logic_error if the context is not a server context.
boolshutdown virtual nodiscard overrideShuts down the connection by attempting an orderly SSL shutdown, then actually shutting down the TCP connection.
voidclose virtual overrideCloses the socket forcefully.
ssize_tsend virtual nodiscard overrideEncrypts and sends len bytes to the connected peer.
ssize_tsendOwned virtual nodiscard overrideSends an owned payload buffer to the connected peer.
ssize_tsend virtual nodiscard overrideEncrypts and sends len bytes, ignoring peerAddress (TCP is connected).
ssize_tsendOwned virtual nodiscard override
voidsetHostnameSet the expected peer hostname for certificate verification and SNI. Must be called before connect() to enable hostname verification.
voiduseContextUse the given SSL context for this socket.
SSLContext::Ptrcontext constReturns the SSL context used for this socket.
voiduseSessionSets the SSL session to use for the next connection. Setting a previously saved Session object is necessary to enable session caching.
SSLSession::PtrcurrentSessionReturns the SSL session of the current connection, for reuse in a future connection (if session caching is enabled).
boolsessionWasReusedReturns true if a reused session was negotiated during the handshake.
intavailable constReturns the number of bytes available from the SSL buffer for immediate reading.
X509 *peerCertificate constReturns the peer's X.509 certificate, or nullptr if no certificate was presented.
net::TransportTypetransport virtual const overrideReturns the SSLTCP transport protocol identifier.
voidacceptConnection virtual overrideAccepts a pending client connection, initializes the server-side SSL context on the new socket, and fires the AcceptConnection signal.
voidonConnect virtual overrideCalled when the TCP connection is established; starts reading and initiates the client-side SSL handshake.
voidonRead virtual overrideFeeds 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

  • loop Event 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

  • sslContext The SSL context to use for this connection.

  • loop Event 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

  • sslContext The SSL context to use for this connection.

  • session A previously saved session to attempt resumption with.

  • loop Event 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

  • peerAddress The 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

  • host Hostname or IP address string.

  • port Destination 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

  • address Local address to bind to.

  • flags Optional 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

  • backlog Maximum 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

  • data Pointer to the plaintext payload.

  • len Number of bytes to send.

  • flags Reserved; 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

  • data Pointer to the plaintext payload.

  • len Number of bytes to send.

  • peerAddress Ignored for SSL/TCP; present for interface conformance.

  • flags Reserved; 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

  • data Pointer to the encrypted bytes.

  • len Number of bytes received.

Reimplements

Protected Attributes

ReturnNameDescription
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

NameDescription
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 >, Socket Subclassed by: SSLSocket

TCP socket implementation.

List of all members

NameKindOwner
AcceptConnectionvariableDeclared here
TCPSocketfunctionDeclared here
TCPSocketfunctionDeclared here
TCPSocketfunctionDeclared here
shutdownfunctionDeclared here
closefunctionDeclared here
connectfunctionDeclared here
connectfunctionDeclared here
sendfunctionDeclared here
sendOwnedfunctionDeclared here
sendfunctionDeclared here
sendOwnedfunctionDeclared here
bindfunctionDeclared here
listenfunctionDeclared here
acceptConnectionfunctionDeclared here
setReusePortfunctionDeclared here
setNoDelayfunctionDeclared here
setKeepAlivefunctionDeclared here
setSimultaneousAcceptsfunctionDeclared here
setModefunctionDeclared here
modefunctionDeclared here
setErrorfunctionDeclared here
errorfunctionDeclared here
closedfunctionDeclared here
addressfunctionDeclared here
peerAddressfunctionDeclared here
transportfunctionDeclared here
loopfunctionDeclared here
onConnectfunctionDeclared here
onReadfunctionDeclared here
onRecvfunctionDeclared here
onErrorfunctionDeclared here
onClosefunctionDeclared here
_modevariableDeclared here
_peerAddressvariableDeclared here
initfunctionDeclared here
resetfunctionDeclared here
PtrtypedefDeclared here
VectypedefDeclared here
HandletypedefInherited from Stream
ReadvariableInherited from Stream
_buffervariableInherited from Stream
_startedvariableInherited from Stream
_highWaterMarkvariableInherited from Stream
_writeReqFreevariableInherited from Stream
_ownedWriteReqFreevariableInherited from Stream
StreamfunctionInherited from Stream
~StreamfunctionInherited from Stream
closefunctionInherited from Stream
shutdownfunctionInherited from Stream
writefunctionInherited from Stream
writeOwnedfunctionInherited from Stream
setHighWaterMarkfunctionInherited from Stream
writefunctionInherited from Stream
streamfunctionInherited from Stream
readStartfunctionInherited from Stream
readStopfunctionInherited from Stream
onReadfunctionInherited from Stream
allocWriteReqfunctionInherited from Stream
freeWriteReqfunctionInherited from Stream
allocOwnedWriteReqfunctionInherited from Stream
freeOwnedWriteReqfunctionInherited from Stream
canQueueWritefunctionInherited from Stream
handleReadfunctionInherited from Stream
allocReadBufferfunctionInherited from Stream
HandlefunctionInherited from Handle
initfunctionInherited from Handle
invokefunctionInherited from Handle
invokeOrThrowfunctionInherited from Handle
closefunctionInherited from Handle
reffunctionInherited from Handle
unreffunctionInherited from Handle
initializedfunctionInherited from Handle
activefunctionInherited from Handle
closingfunctionInherited from Handle
closedfunctionInherited from Handle
errorfunctionInherited from Handle
setErrorfunctionInherited from Handle
setUVErrorfunctionInherited from Handle
setAndThrowErrorfunctionInherited from Handle
throwLastErrorfunctionInherited from Handle
loopfunctionInherited from Handle
resetfunctionInherited from Handle
getfunctionInherited from Handle
tidfunctionInherited from Handle
contextfunctionInherited from Handle
setCloseCleanupfunctionInherited from Handle
clearCloseCleanupfunctionInherited from Handle
assertThreadfunctionInherited from Handle
_loopvariableInherited from Handle
_contextvariableInherited from Handle
_tidvariableInherited from Handle
_errorvariableInherited from Handle
onErrorfunctionInherited from Handle
onClosefunctionInherited from Handle
HandlefunctionInherited from Handle
HandlefunctionInherited from Handle
TypetypedefInherited from Handle
opaquevariableInherited from Socket
SocketfunctionInherited from Socket
SocketfunctionInherited from Socket
SocketfunctionInherited from Socket
connectfunctionInherited from Socket
connectfunctionInherited from Socket
bindfunctionInherited from Socket
listenfunctionInherited from Socket
shutdownfunctionInherited from Socket
sendOwnedfunctionInherited from Socket
sendOwnedfunctionInherited from Socket
closefunctionInherited from Socket
addressfunctionInherited from Socket
peerAddressfunctionInherited from Socket
transportfunctionInherited from Socket
setErrorfunctionInherited from Socket
errorfunctionInherited from Socket
closedfunctionInherited from Socket
loopfunctionInherited from Socket
_afvariableInherited from Socket
initfunctionInherited from Socket
resetfunctionInherited from Socket
PtrtypedefInherited from Socket
VectypedefInherited from Socket
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from Stream

KindNameDescription
typedefHandle
variableReadEmitted when data has been received from the peer.
variable_buffer
variable_started
variable_highWaterMark16MB default write queue limit
variable_writeReqFreeFreelist for write requests.
variable_ownedWriteReqFreeFreelist for owned write requests.
functionStream inlineConstruct the stream bound to loop with a 64 KiB read buffer.
function~Stream virtual inlineDestroy the stream, stopping reads and freeing pooled write requests.
functionclose virtual inline overrideCloses and resets the stream handle. This will close the active socket/pipe and destroy the handle.
functionshutdown inlineSend a TCP/pipe shutdown request to the connected peer.
functionwrite inlineWrite len bytes from data to the stream.
functionwriteOwned inlineWrite an owned payload buffer to the stream.
functionsetHighWaterMark inlineSet the high water mark for the write queue (default 16MB). When the write queue exceeds this size, write() returns false.
functionwrite inlineWrite len bytes from data together with a stream handle over an IPC pipe (uses uv_write2).
functionstream inlineReturn the underlying uv_stream_t pointer cast from the native handle.
functionreadStart virtual inlineBegin reading from the stream by registering libuv read callbacks.
functionreadStop virtual inlineStop reading from the stream.
functiononRead virtual inlineCalled by [handleRead](base.md#classicy_1_1Stream_1ac74fea672c0d281f2a4f51bee6943b10) when len bytes of data arrive.
functionallocWriteReq inlineReturn a uv_write_t from the freelist, or allocate a new one if the pool is empty.
functionfreeWriteReq inlineReturn req to the freelist, or delete it if the pool is at capacity.
functionallocOwnedWriteReq inline
functionfreeOwnedWriteReq inline
functioncanQueueWrite inline
functionhandleRead static inlineUV callbacks.
functionallocReadBuffer static inlinelibuv allocate-buffer callback. Provides the stream's internal buffer, growing it if libuv requests more space than the current allocation.

Inherited from Handle

KindNameDescription
functionHandle inlineConstruct the handle bound to the given event loop.
functioninit inlineInitialize the underlying libuv handle by calling f with the loop, the raw handle pointer, and any additional args.
functioninvoke inlineInvoke a libuv function f with args on the initialized handle.
functioninvokeOrThrow inlineInvoke a libuv function f with args, throwing on failure.
functionclose virtual inlineClose and destroy the handle.
functionref inlineRe-reference the handle with the event loop after a previous [unref()](uv.md#unref).
functionunref inlineUnreference the handle from the event loop.
functioninitialized const inlineReturn true if the handle has been successfully initialized via [init()](uv.md#init-2).
functionactive virtual const inlineReturn true when the handle is active (libuv uv_is_active).
functionclosing virtual const inlineReturn true if uv_close has been called and the handle is awaiting its close callback (libuv uv_is_closing).
functionclosed virtual const inlineReturn true if the handle has been fully closed (context released).
functionerror const inlineReturn the last error set on this handle, or a default-constructed [Error](base.md#error) if no error has occurred.
functionsetError virtual inlineSet the error state and invoke [onError()](uv.md#onerror).
functionsetUVError inlineTranslate a libuv error code into an [Error](base.md#error) and call [setError()](uv.md#seterror).
functionsetAndThrowError inlineSet the error state from a libuv error code and throw a std::runtime_error.
functionthrowLastError inlineThrow a std::runtime_error if the handle currently holds an error.
functionloop const inlineReturn the event loop this handle is bound to.
functionreset inlineClose 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).
functionget const inlineReturn the raw libuv handle pointer cast to [Handle](uv.md#handle-2).
functiontid const inlineReturn the ID of the thread that constructed this handle.
functioncontext const inlineReturn the raw [Context](uv.md#context-1) that owns the libuv handle memory.
functionsetCloseCleanup inline
functionclearCloseCleanup inline
functionassertThread const inlineThrow std::logic_error if called from any thread other than the thread that constructed this handle.
variable_loop
variable_context
variable_tid
variable_error
functiononError virtual inlineCalled by [setError()](uv.md#seterror) after the error state has been updated.
functiononClose virtual inlineCalled by [close()](uv.md#close-11) after the context has been released.
functionHandleNonCopyable and NonMovable.
functionHandleDeleted constructor.
typedefTypeDefine the native handle type.

Inherited from Socket

KindNameDescription
variableopaqueOptional client data.
functionSocketDefaulted constructor.
functionSocketDeleted constructor.
functionSocketDeleted constructor.
functionconnect virtualConnects to the given peer IP address.
functionconnect virtualResolves and connects to the given host address.
functionbind virtualBind a local address to the socket. The address may be IPv4 or IPv6 (if supported).
functionlisten virtual inlineListens the socket on the given address.
functionshutdown virtual inline nodiscardSends the shutdown packet which should result is socket closure via callback.
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionclose virtualCloses the underlying socket.
functionaddress virtual constThe locally bound address.
functionpeerAddress virtual constThe connected peer address.
functiontransport virtual constThe transport protocol: TCP, UDP or SSLTCP.
functionsetError virtualSets the socket error.
functionerror virtual constReturn the socket error if any.
functionclosed virtual constReturns true if the native socket handle is closed.
functionloop virtual constReturns the socket event loop.
variable_af
functioninit virtualInitializes the underlying socket context.
functionreset virtualResets the socket context for reuse.
typedefPtr
typedefVec

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Attributes

ReturnNameDescription
LocalSignal< void(const net::TCPSocket::Ptr &)>AcceptConnectionFired 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

ReturnNameDescription
TCPSocketConstructs the TCPSocket and initializes the underlying libuv handle.
TCPSocketDeleted constructor.
TCPSocketDeleted constructor.
boolshutdown virtual nodiscard overrideSends a TCP shutdown request; the socket closes after the peer acknowledges.
voidclose virtual overrideCloses the socket immediately, releasing all associated resources.
voidconnect virtual overrideConnects to peerAddress using a libuv connect request. On success, calls onConnect(); on failure, calls setUVError().
voidconnect virtual overrideResolves host via DNS (or maps "localhost"), then connects.
ssize_tsend virtual nodiscard overrideWrites len bytes to the connected peer.
ssize_tsendOwned virtual nodiscard overrideSends an owned payload buffer to the connected peer.
ssize_tsend virtual nodiscard overrideWrites len bytes; peerAddress is ignored for TCP (connected stream).
ssize_tsendOwned virtual nodiscard override
voidbind virtual overrideBinds the socket to address. Resets and reinitializes the handle if the address family changes.
voidlisten virtual overrideStarts listening for incoming connections with the given backlog.
voidacceptConnection virtualAccepts the next pending client connection and fires AcceptConnection.
boolsetReusePort nodiscardEnables 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.
boolsetNoDelay nodiscardEnables or disables TCP_NODELAY (Nagle's algorithm).
boolsetKeepAlive nodiscardEnables or disables TCP keep-alive probes.
boolsetSimultaneousAccepts nodiscardEnables or disables simultaneous accepts on Windows. No-op and returns false on non-Windows platforms.
voidsetModeSets the socket mode (ServerSide or ClientSide).
SocketModemode constReturns the current socket mode.
voidsetError virtual overrideSets 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 overrideReturns the current socket error, if any.
boolclosed virtual const overrideReturns true if the native socket handle is closed.
net::Addressaddress virtual const overrideReturns the IP address and port number of the socket. A wildcard address is returned if the socket is not connected.
net::AddresspeerAddress virtual const overrideReturns the IP address and port number of the peer socket. A wildcard address is returned if the socket is not connected.
net::TransportTypetransport virtual const overrideReturns the TCP transport protocol.
uv::Loop *loop virtual const overrideReturns the event loop associated with this socket.
voidonConnect virtualCalled by the stream layer when the TCP connection is established.
voidonRead virtual overrideCalled by the stream layer with raw received bytes; wraps them in a MutableBuffer.
voidonRecv virtualDispatches a received buffer to all socket adapters via onSocketRecv.
voidonError virtual overrideDispatches the error to adapters and closes the socket.
voidonClose virtual overrideDispatches 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

  • loop Event 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

  • peerAddress The 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

  • host Hostname or IP address string.

  • port Destination 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

  • data Pointer to the data to send.

  • len Number of bytes to send.

  • flags Reserved; 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

  • data Pointer to the data to send.

  • len Number of bytes to send.

  • peerAddress Ignored; present for interface conformance.

  • flags Reserved; 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

  • address Local address to bind to.

  • flags Optional 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

  • backlog Maximum 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

  • enable true 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

  • enable true to enable keep-alive.

  • delay Initial 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

  • enable true 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

  • mode The 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

  • err The 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

  • data Pointer to received bytes.

  • len Number 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

  • buf The 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

  • error The 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

ReturnNameDescription
SocketMode_mode
net::Address_peerAddressCached 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

ReturnNameDescription
voidinit virtual overrideInitializes the underlying socket context.
voidreset virtual overrideResets 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

NameDescription
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

NameKindOwner
IntrusivePtrfriendDeclared here
TransactionfunctionDeclared here
sendfunctionDeclared here
cancelfunctionDeclared here
disposefunctionDeclared here
peerAddressfunctionDeclared here
_peerAddressvariableDeclared here
onPacketfunctionDeclared here
onResponsefunctionDeclared here
checkResponsefunctionDeclared here
BaseTtypedefDeclared here
PtrtypedefInherited from PacketTransaction
IntrusivePtrfriendInherited from PacketTransaction
_requestvariableInherited from PacketTransaction
_responsevariableInherited from PacketTransaction
_timervariableInherited from PacketTransaction
_retriesvariableInherited from PacketTransaction
_attemptsvariableInherited from PacketTransaction
_disposedvariableInherited from PacketTransaction
PacketTransactionfunctionInherited from PacketTransaction
PacketTransactionfunctionInherited from PacketTransaction
sendfunctionInherited from PacketTransaction
cancelfunctionInherited from PacketTransaction
cancelledfunctionInherited from PacketTransaction
disposefunctionInherited from PacketTransaction
disposedfunctionInherited from PacketTransaction
canResendfunctionInherited from PacketTransaction
attemptsfunctionInherited from PacketTransaction
retriesfunctionInherited from PacketTransaction
requestfunctionInherited from PacketTransaction
requestfunctionInherited from PacketTransaction
responsefunctionInherited from PacketTransaction
responsefunctionInherited from PacketTransaction
~PacketTransactionfunctionInherited from PacketTransaction
onStateChangefunctionInherited from PacketTransaction
handlePotentialResponsefunctionInherited from PacketTransaction
checkResponsefunctionInherited from PacketTransaction
onResponsefunctionInherited from PacketTransaction
onTimeoutfunctionInherited from PacketTransaction
sendfunctionInherited from Sendable
cancelfunctionInherited from Sendable
StateChangevariableInherited from Stateful
_statevariableInherited from Stateful
StatefulfunctionInherited from Stateful
~StatefulfunctionInherited from Stateful
stateEqualsfunctionInherited from Stateful
stateBetweenfunctionInherited from Stateful
statefunctionInherited from Stateful
statefunctionInherited from Stateful
beforeStateChangefunctionInherited from Stateful
onStateChangefunctionInherited from Stateful
setStatefunctionInherited from Stateful
setStatefunctionInherited from Stateful
_refCountvariableInherited from RefCounted
RefCountedfunctionInherited from RefCounted
RefCountedfunctionInherited from RefCounted
operator=functionInherited from RefCounted
addReffunctionInherited from RefCounted
releaseReffunctionInherited from RefCounted
refCountfunctionInherited from RefCounted
~RefCountedfunctionInherited from RefCounted
factoryvariableInherited from PacketSocketEmitter
PacketSocketEmitterfunctionInherited from PacketSocketEmitter
onSocketRecvfunctionInherited from PacketSocketEmitter
onPacketfunctionInherited from PacketSocketEmitter
ConnectvariableInherited from SocketEmitter
RecvvariableInherited from SocketEmitter
ErrorvariableInherited from SocketEmitter
ClosevariableInherited from SocketEmitter
implvariableInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
SocketEmitterfunctionInherited from SocketEmitter
~SocketEmitterfunctionInherited from SocketEmitter
addReceiverfunctionInherited from SocketEmitter
removeReceiverfunctionInherited from SocketEmitter
swapfunctionInherited from SocketEmitter
asfunctionInherited from SocketEmitter
operator->functionInherited from SocketEmitter
onSocketConnectfunctionInherited from SocketEmitter
onSocketRecvfunctionInherited from SocketEmitter
onSocketErrorfunctionInherited from SocketEmitter
onSocketClosefunctionInherited from SocketEmitter
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from PacketTransaction

KindNameDescription
typedefPtr
friendIntrusivePtr
variable_request
variable_response
variable_timerThe request timeout callback.
variable_retriesThe maximum number of attempts before the transaction is considered failed.
variable_attemptsThe number of times the transaction has been sent.
variable_disposed
functionPacketTransaction inline
functionPacketTransaction inline
functionsend virtual inline overrideStarts the transaction timer and sends the request. Overriding classes should implement send logic here.
functioncancel virtual inline overrideCancellation 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.
functioncancelled const inline
functiondispose virtual inlineStops 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.
functiondisposed const inline nodiscard
functioncanResend virtual inline
functionattempts const inline
functionretries const inline
functionrequest inline
functionrequest const inline
functionresponse inline
functionresponse const inline
function~PacketTransaction virtual inline
functiononStateChange virtual inline overridePost state change hook. Calls dispose() on terminal states to stop the timer, but does not delete the object; IntrusivePtr handles that.
functionhandlePotentialResponse virtual inlineProcesses a potential response candidate and updates the state accordingly.
functioncheckResponse virtualChecks a potential response candidate and returns true on successful match.
functiononResponse virtual inlineCalled when a successful response is received.
functiononTimeout virtual inlineCalled by the timer when the transaction timeout elapses. Retransmits if retries remain, otherwise transitions to Failed.

Inherited from Sendable

KindNameDescription
functionsend virtualInitiates the send operation.
functioncancel virtualCancels a pending send operation.

Inherited from Stateful

KindNameDescription
variableStateChangeSignals when the state changes.
variable_state
functionStateful inline
function~Stateful virtual inline
functionstateEquals virtual const inlineReturns true if the current state ID equals the given ID.
functionstateBetween virtual const inlineReturns true if the current state ID is in the inclusive range [lid, rid].
functionstate virtual inlineReturns a mutable reference to the current state.
functionstate virtual const inlineReturns a copy of the current state.
functionbeforeStateChange virtual inlineOverride to handle pre state change logic. Return false to prevent state change.
functiononStateChange virtual inlineOverride to handle post state change logic.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.

Inherited from RefCounted

KindNameDescription
variable_refCount
functionRefCountedDefaulted constructor.
functionRefCounted inline noexcept
functionoperator= inline noexcept
functionaddRef const inline noexceptIncrements the reference count. Called by IntrusivePtr on acquisition.
functionreleaseRef const inline noexceptDecrements the reference count.
functionrefCount const inline nodiscard noexceptReturns the current reference count.
function~RefCountedDefaulted destructor.

Inherited from PacketSocketEmitter

KindNameDescription
variablefactoryThe packet factory.
functionPacketSocketEmitterCreates the PacketSocketEmitter and attaches it to the given socket.
functiononSocketRecv virtual overrideParses raw received data into packets via the factory and forwards each parsed packet to onPacket(). Returns true if propagation should stop.
functiononPacket virtualProcess a parsed packet. Returns true to stop propagation.

Inherited from SocketEmitter

KindNameDescription
variableConnectSignals that the socket is connected.
variableRecvSignals when data is received by the socket.
variableErrorSignals that the socket is closed in error. This signal will be sent just before the Closed signal.
variableCloseSignals that the underlying socket is closed.
variableimplPointer to the underlying socket. Sent data will be proxied to this socket.
functionSocketEmitterCreates the SocketEmitter and optionally attaches it to a socket. If socket is provided, this emitter registers itself as a receiver.
functionSocketEmitterCopy constructor; copies all signal connections and attaches to the same socket.
function~SocketEmitter virtual noexceptDestroys the SocketAdapter.
functionaddReceiver virtual overrideAttaches a SocketAdapter as a receiver; wires it to all four socket signals.
functionremoveReceiver virtual overrideDetaches a SocketAdapter from all four socket signals.
functionswap virtualReplaces the underlying socket with socket.
functionas inlineReturns the underlying socket cast to type T, or nullptr if the cast fails.
functionoperator-> const inlineReturns a raw pointer to the underlying socket for direct method access. Follows shared_ptr semantics; the caller must not delete the returned pointer.
functiononSocketConnect virtual overrideForwards the connect event to chained adapters, then fires the Connect signal.
functiononSocketRecv virtual overrideForwards the recv event to chained adapters, then fires the Recv signal.
functiononSocketError virtual overrideForwards the error event to chained adapters, then fires the Error signal.
functiononSocketClose virtual overrideForwards the close event to chained adapters, then fires the Close signal.

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Friends

NameDescription
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

ReturnNameDescription
Transaction inlineConstructs a Transaction on the given socket targeting peerAddress.
boolsend virtual inline overrideSends 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.
voidcancel virtual inline overrideCancels the transaction and stops the timeout timer.
voiddispose virtual inline overrideStops the timer and unregisters callbacks.
AddresspeerAddress const inlineReturns 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

  • socket The socket to send/receive packets on.

  • peerAddress The remote address for the request and response matching.

  • timeout Milliseconds to wait for a response before failing.

  • retries Number 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

ReturnNameDescription
Address_peerAddress

{#_peeraddress-1}

_peerAddress

Address _peerAddress

Defined in src/net/include/icy/net/transaction.h:118

Protected Methods

ReturnNameDescription
boolonPacket virtual inline overrideChecks whether packet is a matching response for the pending request. If it matches, the transaction completes; socket data propagation stops.
voidonResponse virtual inline overrideCalled when a confirmed response is received; emits the response via PacketSignal.
boolcheckResponse virtual inline overrideReturns 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

  • packet The 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

  • packet The candidate response packet.

Returns

true if the packet satisfies the response criteria.

Reimplements

Public Types

NameDescription
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

NameKindOwner
UDPSocketfunctionDeclared here
UDPSocketfunctionDeclared here
UDPSocketfunctionDeclared here
connectfunctionDeclared here
connectfunctionDeclared here
closefunctionDeclared here
bindfunctionDeclared here
sendfunctionDeclared here
sendOwnedfunctionDeclared here
sendfunctionDeclared here
sendOwnedfunctionDeclared here
setBroadcastfunctionDeclared here
setMulticastLoopfunctionDeclared here
setMulticastTTLfunctionDeclared here
addressfunctionDeclared here
peerAddressfunctionDeclared here
transportfunctionDeclared here
setErrorfunctionDeclared here
errorfunctionDeclared here
closedfunctionDeclared here
loopfunctionDeclared here
onRecvfunctionDeclared here
_peervariableDeclared here
_buffervariableDeclared here
initfunctionDeclared here
resetfunctionDeclared here
onErrorfunctionDeclared here
onClosefunctionDeclared here
recvStartfunctionDeclared here
recvStopfunctionDeclared here
PtrtypedefDeclared here
VectypedefDeclared here
HandlefunctionInherited from Handle
initfunctionInherited from Handle
invokefunctionInherited from Handle
invokeOrThrowfunctionInherited from Handle
closefunctionInherited from Handle
reffunctionInherited from Handle
unreffunctionInherited from Handle
initializedfunctionInherited from Handle
activefunctionInherited from Handle
closingfunctionInherited from Handle
closedfunctionInherited from Handle
errorfunctionInherited from Handle
setErrorfunctionInherited from Handle
setUVErrorfunctionInherited from Handle
setAndThrowErrorfunctionInherited from Handle
throwLastErrorfunctionInherited from Handle
loopfunctionInherited from Handle
resetfunctionInherited from Handle
getfunctionInherited from Handle
tidfunctionInherited from Handle
contextfunctionInherited from Handle
setCloseCleanupfunctionInherited from Handle
clearCloseCleanupfunctionInherited from Handle
assertThreadfunctionInherited from Handle
_loopvariableInherited from Handle
_contextvariableInherited from Handle
_tidvariableInherited from Handle
_errorvariableInherited from Handle
onErrorfunctionInherited from Handle
onClosefunctionInherited from Handle
HandlefunctionInherited from Handle
HandlefunctionInherited from Handle
TypetypedefInherited from Handle
opaquevariableInherited from Socket
SocketfunctionInherited from Socket
SocketfunctionInherited from Socket
SocketfunctionInherited from Socket
connectfunctionInherited from Socket
connectfunctionInherited from Socket
bindfunctionInherited from Socket
listenfunctionInherited from Socket
shutdownfunctionInherited from Socket
sendOwnedfunctionInherited from Socket
sendOwnedfunctionInherited from Socket
closefunctionInherited from Socket
addressfunctionInherited from Socket
peerAddressfunctionInherited from Socket
transportfunctionInherited from Socket
setErrorfunctionInherited from Socket
errorfunctionInherited from Socket
closedfunctionInherited from Socket
loopfunctionInherited from Socket
_afvariableInherited from Socket
initfunctionInherited from Socket
resetfunctionInherited from Socket
PtrtypedefInherited from Socket
VectypedefInherited from Socket
priorityvariableInherited from SocketAdapter
SocketAdapterfunctionInherited from SocketAdapter
~SocketAdapterfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendOwnedfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
sendPacketfunctionInherited from SocketAdapter
setSenderfunctionInherited from SocketAdapter
senderfunctionInherited from SocketAdapter
addReceiverfunctionInherited from SocketAdapter
removeReceiverfunctionInherited from SocketAdapter
hasReceiverfunctionInherited from SocketAdapter
receiversfunctionInherited from SocketAdapter
onSocketConnectfunctionInherited from SocketAdapter
onSocketRecvfunctionInherited from SocketAdapter
onSocketErrorfunctionInherited from SocketAdapter
onSocketClosefunctionInherited from SocketAdapter
_sendervariableInherited from SocketAdapter
_receiversvariableInherited from SocketAdapter
_dirtyvariableInherited from SocketAdapter
cleanupReceiversfunctionInherited from SocketAdapter

Inherited from Handle

KindNameDescription
functionHandle inlineConstruct the handle bound to the given event loop.
functioninit inlineInitialize the underlying libuv handle by calling f with the loop, the raw handle pointer, and any additional args.
functioninvoke inlineInvoke a libuv function f with args on the initialized handle.
functioninvokeOrThrow inlineInvoke a libuv function f with args, throwing on failure.
functionclose virtual inlineClose and destroy the handle.
functionref inlineRe-reference the handle with the event loop after a previous [unref()](uv.md#unref).
functionunref inlineUnreference the handle from the event loop.
functioninitialized const inlineReturn true if the handle has been successfully initialized via [init()](uv.md#init-2).
functionactive virtual const inlineReturn true when the handle is active (libuv uv_is_active).
functionclosing virtual const inlineReturn true if uv_close has been called and the handle is awaiting its close callback (libuv uv_is_closing).
functionclosed virtual const inlineReturn true if the handle has been fully closed (context released).
functionerror const inlineReturn the last error set on this handle, or a default-constructed [Error](base.md#error) if no error has occurred.
functionsetError virtual inlineSet the error state and invoke [onError()](uv.md#onerror).
functionsetUVError inlineTranslate a libuv error code into an [Error](base.md#error) and call [setError()](uv.md#seterror).
functionsetAndThrowError inlineSet the error state from a libuv error code and throw a std::runtime_error.
functionthrowLastError inlineThrow a std::runtime_error if the handle currently holds an error.
functionloop const inlineReturn the event loop this handle is bound to.
functionreset inlineClose 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).
functionget const inlineReturn the raw libuv handle pointer cast to [Handle](uv.md#handle-2).
functiontid const inlineReturn the ID of the thread that constructed this handle.
functioncontext const inlineReturn the raw [Context](uv.md#context-1) that owns the libuv handle memory.
functionsetCloseCleanup inline
functionclearCloseCleanup inline
functionassertThread const inlineThrow std::logic_error if called from any thread other than the thread that constructed this handle.
variable_loop
variable_context
variable_tid
variable_error
functiononError virtual inlineCalled by [setError()](uv.md#seterror) after the error state has been updated.
functiononClose virtual inlineCalled by [close()](uv.md#close-11) after the context has been released.
functionHandleNonCopyable and NonMovable.
functionHandleDeleted constructor.
typedefTypeDefine the native handle type.

Inherited from Socket

KindNameDescription
variableopaqueOptional client data.
functionSocketDefaulted constructor.
functionSocketDeleted constructor.
functionSocketDeleted constructor.
functionconnect virtualConnects to the given peer IP address.
functionconnect virtualResolves and connects to the given host address.
functionbind virtualBind a local address to the socket. The address may be IPv4 or IPv6 (if supported).
functionlisten virtual inlineListens the socket on the given address.
functionshutdown virtual inline nodiscardSends the shutdown packet which should result is socket closure via callback.
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionclose virtualCloses the underlying socket.
functionaddress virtual constThe locally bound address.
functionpeerAddress virtual constThe connected peer address.
functiontransport virtual constThe transport protocol: TCP, UDP or SSLTCP.
functionsetError virtualSets the socket error.
functionerror virtual constReturn the socket error if any.
functionclosed virtual constReturns true if the native socket handle is closed.
functionloop virtual constReturns the socket event loop.
variable_af
functioninit virtualInitializes the underlying socket context.
functionreset virtualResets the socket context for reuse.
typedefPtr
typedefVec

Inherited from SocketAdapter

KindNameDescription
variablepriorityThe priority of this adapter for STL sort operations.
functionSocketAdapterCreates the SocketAdapter.
function~SocketAdapter virtual noexceptDestroys the SocketAdapter.
functionsend virtual nodiscardSends 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.
functionsend virtual nodiscard
functionsendOwned virtual nodiscardSends an owned payload buffer to the connected peer.
functionsendOwned virtual nodiscard
functionsendPacket virtualSends 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.
functionsendPacket virtual
functionsendPacket virtualSends 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.
functionsetSender virtualSets the pointer to the outgoing data adapter. Send methods proxy data to this adapter by default.
functionsenderReturns the output SocketAdapter pointer.
functionaddReceiver virtualSets the pointer to the incoming data adapter. Events proxy data to this adapter by default.
functionremoveReceiver virtualRemove the given receiver.
functionhasReceiver virtualReturns true if the given receiver is connected.
functionreceiversReturns all currently registered input SocketAdapter pointers. Dead (removed) entries are excluded from the returned list.
functiononSocketConnect virtualCalled 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.
functiononSocketRecv virtualCalled when data is received from the socket. Forwards the event to all registered receivers in priority order.
functiononSocketError virtualCalled when the socket encounters an error. Forwards the event to all registered receivers in priority order.
functiononSocketClose virtualCalled when the socket is closed. Forwards the event to all registered receivers in priority order.
variable_sender
variable_receivers
variable_dirty
functioncleanupReceivers virtual

Public Methods

ReturnNameDescription
UDPSocketConstructs the UDPSocket and initializes the underlying libuv handle.
UDPSocketDeleted constructor.
UDPSocketDeleted constructor.
voidconnect virtual overrideRecords the peer address and fires the Connect signal to mimic TCP socket behaviour. UDP is connectionless; this call does not send any data.
voidconnect virtual overrideResolves host via DNS (or maps "localhost"), then calls connect(Address).
voidclose virtual overrideStops receiving and closes the underlying UDP handle.
voidbind virtual overrideBinds the socket to address and starts the receive loop.
ssize_tsend virtual nodiscard overrideSends len bytes to the previously connected peer address. Returns -1 if no peer address has been set.
ssize_tsendOwned virtual nodiscard overrideSends an owned payload buffer to the connected peer.
ssize_tsend virtual nodiscard overrideSends len bytes to peerAddress. Returns -1 if the socket is uninitialized or the address is not authorized.
ssize_tsendOwned virtual nodiscard override
boolsetBroadcast nodiscardEnables or disables UDP broadcast.
boolsetMulticastLoop nodiscardEnables or disables IP multicast loopback.
boolsetMulticastTTL nodiscardSets the IP multicast time-to-live (hop limit).
net::Addressaddress virtual const overrideReturns the locally bound address, or a wildcard address if unbound.
net::AddresspeerAddress virtual const overrideReturns the connected peer address set by connect(), or a wildcard address if unconnected.
net::TransportTypetransport virtual const overrideReturns the UDP transport protocol.
voidsetError virtual overrideSets the socket error and triggers close.
const icy::Error &error virtual const overrideReturns the current socket error, if any.
boolclosed virtual const overrideReturns true if the native socket handle is closed.
uv::Loop *loop virtual const overrideReturns the event loop associated with this socket.
voidonRecv virtualDispatches 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

  • loop Event 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

  • peerAddress The 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

  • host Hostname or IP address string.

  • port Destination 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

  • address Local address to bind to.

  • flags Optional 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

  • data Pointer to the data to send.

  • len Number of bytes to send.

  • flags Reserved; 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

  • data Pointer to the data to send.

  • len Number of bytes to send.

  • peerAddress Destination address; must match the connected peer if one is set.

  • flags Reserved; 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

  • flag true 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

  • flag true 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

  • ttl Value in the range [1, 255].

Returns

true if the option was set successfully.

Exceptions

  • std::invalid_argument if ttl is 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

  • err The 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

  • buf Buffer containing the received datagram payload.

  • address Address of the sender.

Protected Attributes

ReturnNameDescription
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

ReturnNameDescription
voidinit virtual overrideInitializes the underlying socket context.
voidreset virtual overrideResets the socket context for reuse.
voidonError virtual overrideCalled by [setError()](#seterror-3) after the error state has been updated.
voidonClose virtual overrideCalled by [close()](#close-16) after the context has been released.
boolrecvStart virtual
boolrecvStop 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

  • error The 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

NameDescription
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

NameKindOwner
VerificationErrorDetailsfunctionDeclared here
~VerificationErrorDetailsfunctionDeclared here
certificatefunctionDeclared here
errorDepthfunctionDeclared here
errorNumberfunctionDeclared here
errorMessagefunctionDeclared here
setIgnoreErrorfunctionDeclared here
getIgnoreErrorfunctionDeclared here
_certvariableDeclared here
_errorDepthvariableDeclared here
_errorNumbervariableDeclared here
_errorMessagevariableDeclared here
_ignoreErrorvariableDeclared here

Public Methods

ReturnNameDescription
VerificationErrorDetailsCreates the VerificationErrorDetails. _ignoreError is per default set to false.
~VerificationErrorDetails noexceptDestroys the VerificationErrorDetails.
const crypto::X509Certificate &certificate const inlineReturns the certificate that caused the error.
interrorDepth const inlineReturns the position of the certificate in the certificate chain.
interrorNumber const inlineReturns the id of the error.
const std::string &errorMessage const inlineReturns the textual presentation of the errorNumber.
voidsetIgnoreError inlinesetIgnoreError to true, if a verification error is judged non-fatal by the user.
boolgetIgnoreError const inlinereturns 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

ReturnNameDescription
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

NameKindOwner
socketvariableDeclared here
peerAddressvariableDeclared here
PacketInfofunctionDeclared here
PacketInfofunctionDeclared here
clonefunctionDeclared here
IPacketInfofunctionInherited from IPacketInfo
~IPacketInfofunctionInherited from IPacketInfo
clonefunctionInherited from IPacketInfo

Inherited from IPacketInfo

KindNameDescription
functionIPacketInfoDefaulted constructor.
function~IPacketInfo virtualDefaulted destructor.
functionclone virtual constReturns a heap-allocated deep copy of this info object.

Public Attributes

ReturnNameDescription
Socket::PtrsocketThe source socket.
AddresspeerAddressThe 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

ReturnNameDescription
PacketInfo inlineConstructs PacketInfo with the originating socket and peer address.
PacketInfo inlineCopy constructor.
std::unique_ptr< IPacketInfo >clone virtual const inlineReturns 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

  • socket Shared pointer to the socket that received the packet.

  • peerAddress Address 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


{#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

ReturnNameDescription
autoresolve inlineResolves 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

  • host Hostname or IP address string to resolve.

  • port Port number to associate with the resolved address.

  • callback Invoked with (status, resolved Address); status is 0 on success.

  • loop Event loop to use; defaults to the default loop.

Returns

A request handle whose lifetime controls the in-flight DNS query.