|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
Socket transports, wire protocols, and the NetworkManager connection/channel layer (including the built-in HTTP/WebSocket server). More...
Socket transports, wire protocols, and the NetworkManager connection/channel layer (including the built-in HTTP/WebSocket server).
The two classes you normally touch:
isAsync=true and a NetworkReceiver whose receiveMessage() override handles each message on the connection's thread.isAsync=false) and loop on NetworkChannel::waitForHTTPRequest() + sendHTTPReply(). HTTPReply also serves files from disk (createFromFile(), with If-Modified-Since/304 support), canned error pages (createErrorPage()), Basic-auth challenges and CORS preflight responses._USE_SSL_ / OpenSSL). Servers need a certificate first; client-side peer verification policy is configurable per manager, per channel or process-wide: isAsync=true) callbacks arrive on each connection's own protocol thread — receivers must be thread-safe. Objects handed to receive*() callbacks become yours when you return true (delete them); objects returned by waitFor*() and makeHTTPRequest() are always owned by the caller. Send methods never take ownership of the object passed in. Connection lifecycle changes (connect/disconnect/reconnect, buffer pressure, protocol errors) are reported as NetworkEvent notifications (NETWORKEVENT_* types). autoreconnect=true are transparently re-established by the manager's supervision thread. Files | |
| file | ConsoleOutput.h |
| Levelled console logging: verbose, debug and error printf-style output with per-subject filtering. | |
| file | HTML.h |
| HTML/URL helper utilities: entity encoding/decoding, MIME type lookup and URL component parsing. | |
| file | NetworkManager.h |
| Connection/channel management layer: multi-protocol listeners, typed dispatch, HTTP client — and the CMSDK's built-in HTTP/WebSocket server. | |
| file | NetworkProtocols.h |
| Wire-protocol layer: HTTP request/reply, WebSocket frames, Telnet lines, binary DataMessages, and protocol auto-detection. | |
| file | ConsoleOutput.cpp |
| Implementation of the levelled console logging functions: per-subject verbose/debug/error filtering and printf-style output. | |
| file | HTML.cpp |
| Implementation of the HTML/URL helpers: entity encode/decode tables, extension-to-MIME-type mapping and URL component extraction. | |
| file | NetworkConnections.cpp |
| Implementation of the raw socket transports: TCPListener, TCPConnection, UDPConnection and SSLConnection (OpenSSL). | |
| file | NetworkManager.cpp |
| Implementation of NetworkManager, NetworkChannel and NetworkThread: channel/connection lifecycle, protocol worker threads (HTTP server/client, message, telnet, WebSocket), protocol auto-detection and the blocking makeHTTPRequest() client, plus networking unit tests. | |
| file | NetworkProtocols.cpp |
| Implementation of the wire-protocol layer: HTTPRequest/HTTPReply parsing and generation, WebSocket (RFC 6455) framing with masking and extended payload lengths in network byte order, Telnet lines, JSONM multipart containers and the protocol auto-detection checks. | |
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... | |
| struct | cmlabs::NetworkEvent |
| Notification of a connection lifecycle change (connect, disconnect, buffer state...). More... | |
| class | cmlabs::NetworkReceiver |
| Callback interface for asynchronous delivery of parsed network traffic. More... | |
| class | cmlabs::HTTPTestServer |
| Minimal HTTP server used by the unit tests: replies with a canned page. More... | |
| class | cmlabs::WebsocketTestServer |
| Minimal WebSocket echo server used by the unit tests (handles upgrade + echo). More... | |
| class | cmlabs::NetworkManager |
| Central owner of all channels, listeners and connections in a process. More... | |
| class | cmlabs::NetworkThread |
| Bookkeeping for one worker thread of a NetworkChannel (per listener or connection). More... | |
| class | cmlabs::NetworkChannel |
| One logical network interface: a group of listeners/connections with shared dispatch. More... | |
| class | cmlabs::HTTPPostEntry |
| One named entry of an HTTP POST body (form field or uploaded file part). More... | |
| class | cmlabs::HTTPRequest |
| A parsed or generated HTTP request (also used for WebSocket upgrade handshakes). More... | |
| struct | cmlabs::JSONMEntry |
| Metadata for one binary attachment chunk inside a JSONM container. More... | |
| class | cmlabs::JSONM |
| JSONM: a JSON document with attached binary chunks in one contiguous buffer. More... | |
| class | cmlabs::WebsocketData |
| One WebSocket frame/message (RFC 6455): parsing, generation and control frames. More... | |
| class | cmlabs::TelnetLine |
| One line of Telnet-style text traffic. More... | |
| class | cmlabs::HTTPReply |
| A parsed or generated HTTP response. More... | |
| class | cmlabs::NetworkProtocol |
| Base class for the protocol auto-detection framework. More... | |
| class | cmlabs::HTTPProtocol |
| Server-side HTTP/WebSocket protocol handler (static send/receive helpers). More... | |
| class | cmlabs::HTTPClientProtocol |
| Client-side HTTP protocol handler (mirror of HTTPProtocol for outgoing requests). More... | |
| class | cmlabs::MessageProtocol |
| Binary DataMessage protocol handler: size-prefixed serialised messages. More... | |
| class | cmlabs::TelnetProtocol |
| Telnet line protocol handler for interactive text connections. More... | |
Functions | |
| 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. | |
| bool cmlabs::NetworkTest_SendReceiveData | ( | TCPConnection * | con, |
| char * | data, | ||
| uint32 | dataLen, | ||
| uint32 | c, | ||
| bool | receiveFirst = false ) |
Send-and-verify helper used by the TCP tests.
| con | Connection under test. |
| data | Payload buffer. |
| dataLen | Payload size. |
| c | Iteration index. |
| receiveFirst | Receive before sending when true. |
Definition at line 2968 of file NetworkConnections.cpp.
References cmlabs::NetworkConnection::receive(), and cmlabs::TCPConnection::send().
| bool cmlabs::NetworkTest_TCPClient | ( | const char * | address, |
| uint16 | port, | ||
| uint32 | count = 0 ) |
Loopback test client matching NetworkTest_TCPServer().
| address | Server host. |
| port | Server port. |
| count | Exchanges (0 = default). |
Definition at line 2843 of file NetworkConnections.cpp.
References cmlabs::TCPConnection::connect(), GetTimeNow(), cmlabs::NetworkConnection::isConnected(), cmlabs::NetworkConnection::receive(), and cmlabs::TCPConnection::send().
| bool cmlabs::NetworkTest_TCPServer | ( | uint16 | port, |
| uint32 | count = 0 ) |
Loopback test server: listens on port and echoes test payloads.
| port | TCP port to listen on. |
| count | Number of exchanges (0 = default). |
Definition at line 2766 of file NetworkConnections.cpp.
References cmlabs::TCPListener::acceptConnection(), cmlabs::TCPListener::init(), cmlabs::NetworkConnection::isConnected(), NOENC, cmlabs::NetworkConnection::receive(), and cmlabs::NetworkConnection::send().
| THREAD_RET THREAD_FUNCTION_CALL cmlabs::TCPConnectionRun | ( | THREAD_ARG | arg | ) |
Thread entry point for a TCPConnection's push-mode reader loop.
Definition at line 2749 of file NetworkConnections.cpp.
| THREAD_RET THREAD_FUNCTION_CALL cmlabs::TCPListenerRun | ( | THREAD_ARG | arg | ) |
Thread entry point for a TCPListener's internal accept loop.
Definition at line 2744 of file NetworkConnections.cpp.
| THREAD_RET THREAD_FUNCTION_CALL cmlabs::UDPConnectionRun | ( | THREAD_ARG | arg | ) |
Thread entry point for a UDPConnection's push-mode reader loop.
Definition at line 2754 of file NetworkConnections.cpp.