net
net
Socket transports, adapters, and address helpers.
Classes
| Name | Description |
|---|---|
Address | Represents an IPv4 or IPv6 socket address with host and port. |
PacketSocketEmitter | Socket adapter that emits received data as packets. |
Socket | Base socket implementation from which all sockets derive. |
SocketAdapter | Abstract adapter interface for socket send/receive chains. |
SocketEmitter | SocketAdapter that exposes socket events as signals. |
SocketPacket | Default packet type emitted by sockets. |
SSLAdapter | Manages the OpenSSL context and BIO buffers for an SSL socket connection. |
SSLContext | OpenSSL SSL_CTX wrapper for client and server TLS configuration. |
SSLManager | Singleton that owns the default client/server TLS contexts and related callbacks. |
SSLSession | Cached SSL/TLS session wrapper used for client-side resumption. |
SSLSocket | SSL socket implementation. |
TCPSocket | TCP socket implementation. |
Transaction | Request/response helper for packet types emitted from a socket. |
UDPSocket | UDP socket implementation. |
VerificationErrorDetails | A utility class for certificate error handling. |
PacketInfo | Provides information about packets emitted from a socket. See SocketPacket. |
Enumerations
| Name | Description |
|---|---|
TransportType | Transport protocol identifier used to distinguish socket types at runtime. |
SocketMode | Transport mode for socket adapters and accepted connections. |
TransportType
enum TransportTypeTransport protocol identifier used to distinguish socket types at runtime.
| Value | Description |
|---|---|
UDP | Unreliable datagram protocol. |
TCP | Reliable stream protocol. |
SSLTCP | TLS-encrypted TCP stream. |
SocketMode
enum SocketModeTransport mode for socket adapters and accepted connections.
| Value | Description |
|---|---|
ServerSide | Server-side adapter. |
ClientSide | Client-side adapter. |
Functions
| Return | Name | Description |
|---|---|---|
std::shared_ptr< SocketT > | makeSocket inline | Creates a socket of type SocketT wrapped in a shared_ptr. |
SSLContext::VerificationMode | convertVerificationMode inline | Non-case sensitive conversion of a string to a VerificationMode enum. If verMode is illegal an ArgumentException is thrown. |
std::string | convertCertificateError inline | Converts an SSL certificate handling error code into an error message. |
std::string | getLastError inline | Returns the last error from the error stack. |
void | clearErrorStack inline | Clears the error stack. |
void | getNetworkInterfaces inline | Populates hosts with all local network interface addresses. |
int | getServerSocketSendBufSize | Returns the current send buffer size for a socket handle, in bytes. Passes val=0 to uv_send_buffer_size, which queries rather than sets the value. |
int | getServerSocketRecvBufSize | Returns the current receive buffer size for a socket handle, in bytes. Passes val=0 to uv_recv_buffer_size, which queries rather than sets the value. |
int | setServerSocketSendBufSize | Sets the send buffer size for a socket handle. |
int | setServerSocketRecvBufSize | Sets the receive buffer size for a socket handle. |
makeSocket
inline
template<class SocketT> inline std::shared_ptr< SocketT > makeSocket(uv::Loop * loop)Creates a socket of type SocketT wrapped in a shared_ptr.
The socket is automatically destroyed when the last shared_ptr owner releases it.
Parameters
Parameters
loopEvent loop to associate with the socket; defaults to the default loop.
Returns
A shared_ptr owning the newly created socket.
convertVerificationMode
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
inline
inline std::string convertCertificateError(long errCode)Converts an SSL certificate handling error code into an error message.
getLastError
inline
inline std::string getLastError()Returns the last error from the error stack.
clearErrorStack
inline
inline void clearErrorStack()Clears the error stack.
getNetworkInterfaces
inline
inline void getNetworkInterfaces(std::vector< net::Address > & hosts)Populates hosts with all local network interface addresses.
Each entry is an IPv4 address constructed from the interface's address4 field. The results include loopback and any other active interfaces reported by libuv.
Parameters
hostsVector to append the discovered addresses to.
getServerSocketSendBufSize
template<typename T> int getServerSocketSendBufSize(uv::Handle< T > & handle)Returns the current send buffer size for a socket handle, in bytes. Passes val=0 to uv_send_buffer_size, which queries rather than sets the value.
Parameters
TThe libuv handle type (e.g. uv_tcp_t, uv_udp_t).
Parameters
handleThe socket handle to query.
Returns
The send buffer size, or a libuv error code on failure.
getServerSocketRecvBufSize
template<typename T> int getServerSocketRecvBufSize(uv::Handle< T > & handle)Returns the current receive buffer size for a socket handle, in bytes. Passes val=0 to uv_recv_buffer_size, which queries rather than sets the value.
Parameters
TThe libuv handle type (e.g. uv_tcp_t, uv_udp_t).
Parameters
handleThe socket handle to query.
Returns
The receive buffer size, or a libuv error code on failure.
setServerSocketSendBufSize
template<typename T> int setServerSocketSendBufSize(uv::Handle< T > & handle, int size)Sets the send buffer size for a socket handle.
Parameters
TThe libuv handle type (e.g. uv_tcp_t, uv_udp_t).
Parameters
handleThe socket handle to configure.sizeThe desired send buffer size in bytes.
Returns
0 on success, or a libuv error code on failure.
setServerSocketRecvBufSize
template<typename T> int setServerSocketRecvBufSize(uv::Handle< T > & handle, int size)Sets the receive buffer size for a socket handle.
Parameters
TThe libuv handle type (e.g. uv_tcp_t, uv_udp_t).
Parameters
handleThe socket handle to configure.sizeThe desired receive buffer size in bytes.
Returns
0 on success, or a libuv error code on failure.
Variables
| Return | Name | Description |
|---|---|---|
constexpr int | MAX_TCP_PACKET_SIZE | Maximum size of a single TCP receive buffer, in bytes. |
constexpr int | MAX_UDP_PACKET_SIZE | Maximum size of a single UDP datagram payload, in bytes. |
MAX_TCP_PACKET_SIZE
constexpr int MAX_TCP_PACKET_SIZE = 64 * 1024Maximum size of a single TCP receive buffer, in bytes.
MAX_UDP_PACKET_SIZE
constexpr int MAX_UDP_PACKET_SIZE = 1500Maximum size of a single UDP datagram payload, in bytes.
