|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
Raw socket transport layer: TCP/UDP/SSL connections and TCP listeners with buffered, thread-safe I/O. More...
Go to the source code of this file.
Classes | |
| class | cmlabs::NetworkConnectionReceiver |
| Callback interface for asynchronous delivery of newly accepted connections. More... | |
| class | cmlabs::NetworkDataReceiver |
| Callback interface for asynchronous (push) delivery of received bytes. More... | |
| class | cmlabs::TCPListener |
| TCP server socket: binds a port and accepts inbound connections (plain or SSL). More... | |
| class | cmlabs::NetworkConnection |
| Abstract base class for all point-to-point network connections. More... | |
| class | cmlabs::UDPConnection |
| UDP datagram connection (bound port for input, or output-only sender). More... | |
| class | cmlabs::TCPConnection |
| Plain TCP stream connection (client-initiated or accepted from a listener). More... | |
| class | cmlabs::SSLConnection |
| SSL/TLS-encrypted TCP connection (OpenSSL) with configurable peer verification. More... | |
Namespaces | |
| namespace | cmlabs |
Macros | |
| #define | INITIALBUFFERSIZE 4096 |
| Initial size in bytes of a connection's internal receive buffer; it grows on demand via NetworkConnection::resizeBuffer(). | |
Encryption modes | |
Values accepted by listener/connection factory functions to select the transport security applied to a TCP stream. | |
| #define | NOENC 1 |
| Plain, unencrypted transport. | |
| #define | SSLENC 2 |
SSL/TLS encryption (requires build with _USE_SSL_). | |
| #define | AESENC 3 |
| AES encryption (reserved; not currently implemented). | |
Connection types | |
Values returned by NetworkConnection::getConnectionType(). | |
| #define | TCPCON 1 |
| Plain TCP stream connection. | |
| #define | UDPCON 2 |
| UDP datagram connection. | |
| #define | SSLCON 3 |
| SSL/TLS-encrypted TCP connection. | |
| #define | AESCON 4 |
| AES-encrypted connection (reserved). | |
Network error codes | |
Error identifiers passed to NetworkConnectionReceiver::registerError() and NetworkDataReceiver::registerError(), and to disconnect(). | |
| #define | NETWORKERROR_ACCEPT 1 |
| accept() failed on a listener socket. | |
| #define | NETWORKERROR_RECEIVE 2 |
| A read from the socket failed (peer closed or socket error). | |
| #define | NETWORKERROR_SEND_ERROR 3 |
| A write to the socket failed. | |
| #define | NETWORKERROR_SEND_TIMEOUT 4 |
| A write could not complete within the timeout. | |
| #define | NETWORKERROR_MEMORYFULL 5 |
| The receive buffer could not grow to hold incoming data. | |
| #define | NETWORKERROR_GREETING_ERROR 6 |
| The initial greeting/handshake data exchange failed. | |
Functions | |
| THREAD_RET THREAD_FUNCTION_CALL | cmlabs::SSLConnectionRun (THREAD_ARG arg) |
| THREAD_RET THREAD_FUNCTION_CALL | cmlabs::TCPListenerRun (THREAD_ARG arg) |
| Thread entry point for a TCPListener's internal accept loop. | |
| THREAD_RET THREAD_FUNCTION_CALL | cmlabs::TCPConnectionRun (THREAD_ARG arg) |
| Thread entry point for a TCPConnection's push-mode reader loop. | |
| THREAD_RET THREAD_FUNCTION_CALL | cmlabs::UDPConnectionRun (THREAD_ARG arg) |
| Thread entry point for a UDPConnection's push-mode reader loop. | |
| bool | cmlabs::NetworkTest_TCPServer (uint16 port, uint32 count=0) |
Loopback test server: listens on port and echoes test payloads. | |
| bool | cmlabs::NetworkTest_TCPClient (const char *address, uint16 port, uint32 count=0) |
| Loopback test client matching NetworkTest_TCPServer(). | |
| bool | cmlabs::NetworkTest_SendReceiveData (TCPConnection *con, char *data, uint32 dataLen, uint32 c, bool receiveFirst=false) |
| Send-and-verify helper used by the TCP tests. | |
Raw socket transport layer: TCP/UDP/SSL connections and TCP listeners with buffered, thread-safe I/O.
This header defines the lowest layer of the CMSDK networking stack: the classes that own actual OS sockets. Above it sit NetworkProtocols.h (wire formats: HTTP, WebSocket, Telnet, binary messages) and NetworkManager.h (channel/connection lifecycle management and dispatch).
Class roles:
_USE_SSL_ is defined).arpa/inet.h supplies htonl()/ntohl() byte-order conversion. All multi-byte values sent on the wire are converted to network byte order (big-endian) with htonl()/htons() so that mixed-endian hosts interoperate. The implementation (NetworkConnections.cpp) isolates these differences behind #ifdef WINDOWS / WIN32 / _WIN64 branches.Definition in file NetworkConnections.h.
| #define AESCON 4 |
AES-encrypted connection (reserved).
Definition at line 362 of file NetworkConnections.h.
| #define AESENC 3 |
AES encryption (reserved; not currently implemented).
Definition at line 354 of file NetworkConnections.h.
Referenced by cmlabs::TCPListener::acceptConnection().
| #define INITIALBUFFERSIZE 4096 |
Initial size in bytes of a connection's internal receive buffer; it grows on demand via NetworkConnection::resizeBuffer().
Definition at line 367 of file NetworkConnections.h.
Referenced by cmlabs::NetworkConnection::NetworkConnection(), cmlabs::SSLConnection::readIntoBuffer(), cmlabs::NetworkConnection::receiveAvailable(), and cmlabs::NetworkConnection::run().
| #define NETWORKERROR_ACCEPT 1 |
accept() failed on a listener socket.
Definition at line 372 of file NetworkConnections.h.
Referenced by cmlabs::TCPListener::acceptConnection().
| #define NETWORKERROR_GREETING_ERROR 6 |
The initial greeting/handshake data exchange failed.
Definition at line 377 of file NetworkConnections.h.
Referenced by cmlabs::NetworkChannel::HTTPClientRun(), and cmlabs::NetworkChannel::MessageConnectionRun().
| #define NETWORKERROR_MEMORYFULL 5 |
The receive buffer could not grow to hold incoming data.
Definition at line 376 of file NetworkConnections.h.
Referenced by cmlabs::NetworkConnection::run().
| #define NETWORKERROR_RECEIVE 2 |
A read from the socket failed (peer closed or socket error).
Definition at line 373 of file NetworkConnections.h.
Referenced by cmlabs::NetworkConnection::readIntoBuffer(), cmlabs::SSLConnection::readIntoBuffer(), cmlabs::SSLConnection::receive(), cmlabs::NetworkConnection::receiveAvailable(), cmlabs::SSLConnection::receiveAvailable(), and cmlabs::SSLConnection::send().
| #define NETWORKERROR_SEND_ERROR 3 |
A write to the socket failed.
Definition at line 374 of file NetworkConnections.h.
Referenced by cmlabs::TCPConnection::send(), and cmlabs::UDPConnection::send().
| #define NETWORKERROR_SEND_TIMEOUT 4 |
A write could not complete within the timeout.
Definition at line 375 of file NetworkConnections.h.
Referenced by cmlabs::SSLConnection::send(), cmlabs::TCPConnection::send(), and cmlabs::UDPConnection::send().
| #define NOENC 1 |
Plain, unencrypted transport.
Definition at line 352 of file NetworkConnections.h.
Referenced by cmlabs::NetworkChannel::addTCPConnection(), cmlabs::NetworkChannel::addTCPConnection(), cmlabs::RequestGatewayConnection::clear(), cmlabs::NetworkChannel::createTCPConnection(), cmlabs::NetworkChannel::createTCPConnection(), cmlabs::NetworkChannel::createTCPConnection(), cmlabs::NetworkChannel::createWebsocketConnection(), cmlabs::NetworkChannel::createWebsocketConnection(), cmlabs::HTTPServerTest(), cmlabs::NetworkManager::makeHTTPRequest(), cmlabs::NetworkManager::makeHTTPRequest(), cmlabs::NetworkManager::makeHTTPRequest(), cmlabs::NetworkManager::makeHTTPRequest(), cmlabs::NetworkTest_TCPServer(), cmlabs::TestRequestClient::run(), cmlabs::TestWebRequestClient::run(), cmlabs::TestWebSocketRequestClient::run(), cmlabs::TCPListener::TCPListener(), cmlabs::Test_RequestClient(), cmlabs::NetworkManager::TestHTTP(), cmlabs::RequestClient::TestServerLogin(), cmlabs::NetworkManager::UnitTest(), cmlabs::RequestGateway::UnitTest(), cmlabs::NetworkManager::UnitTestDelayedConnect(), cmlabs::NetworkManager::UnitTestHTTP(), and cmlabs::NetworkManager::WebsocketTest().
| #define SSLCON 3 |
SSL/TLS-encrypted TCP connection.
Definition at line 361 of file NetworkConnections.h.
Referenced by cmlabs::SSLConnection::SSLConnection().
| #define SSLENC 2 |
SSL/TLS encryption (requires build with _USE_SSL_).
Definition at line 353 of file NetworkConnections.h.
Referenced by cmlabs::TCPListener::acceptConnection(), cmlabs::RequestGateway::addPort(), cmlabs::NetworkChannel::addTCPConnection(), cmlabs::NetworkChannel::addTCPConnection(), cmlabs::NetworkChannel::createTCPConnection(), cmlabs::NetworkChannel::createTCPConnection(), cmlabs::NetworkChannel::createTCPConnection(), cmlabs::NetworkChannel::createWebsocketConnection(), cmlabs::NetworkChannel::createWebsocketConnection(), cmlabs::NetworkManager::makeHTTPRequest(), cmlabs::NetworkManager::makeHTTPRequest(), cmlabs::NetworkManager::makeHTTPRequest(), cmlabs::NetworkManager::makeHTTPRequest(), and cmlabs::RequestGateway::UnitTest().
| #define TCPCON 1 |
Plain TCP stream connection.
Definition at line 359 of file NetworkConnections.h.
Referenced by cmlabs::NetworkConnection::readIntoBuffer(), and cmlabs::TCPConnection::TCPConnection().
| #define UDPCON 2 |
UDP datagram connection.
Definition at line 360 of file NetworkConnections.h.
Referenced by cmlabs::NetworkConnection::isConnected(), cmlabs::SSLConnection::isConnected(), cmlabs::NetworkConnection::readIntoBuffer(), and cmlabs::UDPConnection::UDPConnection().