Gin
Loading...
Searching...
No Matches
SecureStreamingSocket Class Reference

Streaming socket with optional TLS/SSL encryption support. More...

#include <gin_securestreamingsocket.h>

Public Member Functions

 SecureStreamingSocket (bool secure=true)
 ~SecureStreamingSocket ()
bool connect (const juce::String &remoteHostname, int remotePortNumber, int timeOutMillisecs=3000)
void close ()
bool isConnected () const noexcept
int read (void *destBuffer, int maxBytesToRead, bool blockUntilSpecifiedAmountHasArrived)
int write (const void *sourceBuffer, int numBytesToWrite)
int getRawSocketHandle () const noexcept
int waitUntilReady (bool readyForReading, int timeoutMsecs)

Detailed Description

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:

SecureStreamingSocket socket(true); // true = secure (TLS/SSL)
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)
{
// Process received data
}
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

Constructor & Destructor Documentation

◆ SecureStreamingSocket()

SecureStreamingSocket::SecureStreamingSocket ( bool secure = true)

◆ ~SecureStreamingSocket()

SecureStreamingSocket::~SecureStreamingSocket ( )

Member Function Documentation

◆ connect()

bool SecureStreamingSocket::connect ( const juce::String & remoteHostname,
int remotePortNumber,
int timeOutMillisecs = 3000 )

◆ close()

void SecureStreamingSocket::close ( )

◆ isConnected()

bool SecureStreamingSocket::isConnected ( ) const
noexcept

◆ read()

int SecureStreamingSocket::read ( void * destBuffer,
int maxBytesToRead,
bool blockUntilSpecifiedAmountHasArrived )

References read().

Referenced by read().

◆ write()

int SecureStreamingSocket::write ( const void * sourceBuffer,
int numBytesToWrite )

References write().

Referenced by write().

◆ getRawSocketHandle()

int SecureStreamingSocket::getRawSocketHandle ( ) const
noexcept

References getRawSocketHandle().

Referenced by getRawSocketHandle().

◆ waitUntilReady()

int SecureStreamingSocket::waitUntilReady ( bool readyForReading,
int timeoutMsecs )

References waitUntilReady().

Referenced by waitUntilReady().


The documentation for this class was generated from the following file: