Skip to content

ida64/TcpSocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TcpSocket

A Windows TCP socket class with optional SSL support

Configuration

#define SSL_ENABLED // Comment this line to disable SSL support
#define SSL_CERT_FILE "cert.pem" // Path to the certificate file
#define SSL_KEY_FILE "key.pem" // Path to the key file

Client

	// Create a TCPSocket object
	TCPSocket* Socket = TCPSocket::Create();

	// Connect to the server
	if (!Socket->Connect("127.0.0.1", 8880))
	{
		...
	}

	// Send a message to the server
	char Data[] = "Hello, world!";
	SIZE_T Sent = Socket->Send(Data, sizeof(Data));
	if (!Sent)
	{
		...
	}

	Socket->Disconnect();

Server

	TCPSocket* Socket = TCPSocket::Create();
	if (!Socket->Bind("127.0.0.1", 8880))
	{
		...
	}

	SOCKET client = Socket->Accept();
	if (client == INVALID_SOCKET)
	{
		...
	}

	BYTE buffer[14];
	memset(buffer, 0, sizeof(buffer));
	if (Socket->Recv(client, buffer, sizeof(buffer)) == 0)
	{
		...
	}

	printf("Received: %s\n", buffer);

	socket->Disconnect();

About

Windows TCP Sockets with SSL

Resources

License

Stars

Watchers

Forks

Languages