Gin
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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:

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();
}
A lightweight 2D point class for projects that don't use juce_graphics.
Definition gin_point.h:25
Streaming socket with optional TLS/SSL encryption support.
Definition gin_securestreamingsocket.h:54

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 
)

◆ write()

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

◆ getRawSocketHandle()

int SecureStreamingSocket::getRawSocketHandle ( ) const
noexcept

◆ waitUntilReady()

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

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