The Cross-Platform SSLSocket Library provides a simple way to create secure socket connections using SSL/TLS on both Windows and macOS. This library uses SChannel on Windows and Secure Transport on macOS to handle SSL/TLS connections.
- Cross-platform support for Windows and macOS
- Secure SSL/TLS connections
- Simple API for connecting, sending, and receiving data
- Include the
ssl-socket.h
andssl-socket.cpp
files in your project. - Link against the necessary libraries:
- On Windows, link against
ws2_32.lib
andsecur32.lib
. - On macOS, no additional linking is required as Secure Transport is part of the system libraries.
- On Windows, link against
- Constructor:
ssl-socket(const std::string& host, int port)
- Initializes a new instance of the
ssl-socket
class.
- Initializes a new instance of the
- Destructor:
~ssl-socket()
- Cleans up resources.
- bool connect()
- Establishes a secure connection to the specified host and port.
- Returns
true
if the connection is successful,false
otherwise.
- int send(const std::string& data)
- Sends data over the secure connection.
- Returns the number of bytes sent, or
-1
on error.
- std::string receive()
- Receives data from the secure connection.
- Returns the received data as a string.
- void close()
- Closes the secure connection.
- Windows: Uses SChannel for SSL/TLS connections.
- macOS: Uses Secure Transport for SSL/TLS connections.