Streaming socket with optional TLS/SSL encryption support.
SecureStreamingSocket provides a unified interface for both secure (HTTPS/TLS) and non-secure (HTTP) streaming socket connections. It wraps mbedTLS for secure connections and falls back to JUCE's StreamingSocket for non-secure connections.
Key Features:
- TLS/SSL support via mbedTLS
- Fallback to plain sockets when security not required
- Blocking and non-blocking read modes
- Timeout support for connections and reads
- Compatible with WebSocket and HTTP implementations
Usage:
if (socket.connect("example.com", 443, 3000))
{
const char* request = "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n";
socket.write(request, strlen(request));
char buffer[1024];
int bytesRead = socket.read(buffer, sizeof(buffer), false);
if (bytesRead > 0)
{
}
socket.close();
}
SecureStreamingSocket(bool secure=true)
Thread Safety: Not thread-safe. Use from a single thread or provide external synchronization.
- See also
- WebSocket, Http, AsyncWebsocket