I was working with OpenSSL and VC++, I found that there are very few references available which tell us how to implement OpenSSL through VC++. But real thing missing  is Working Client server in VC++ which will communicate through OpenSSL. So Writing one

Lets start with WinSock2 client server.

VC++ Code details

  1. VS2005

VC++ references required:
(From MSDN)Use the Winsock API by including the Winsock 2 header files. The Winsock2.h header file contains most of the Winsock functions, structures, and definitions. The Ws2tcpip.h header file contains definitions introduced in the WinSock 2 Protocol-Specific Annex document for TCP/IP that includes newer functions and structures used to retrieve IP addresses.

  1. Add #include <winsock2.h> and #include <ws2tcpip.h> in code
  2. Add build environment links to the Winsock Library file WS2_32.lib

Source code : click this link WinSock2-BasicClientServer

WinSock2 Server

We need to follow following steps to implement Server

  1. Initialize Winsock.
  2. Create and Bind the socket.
  3. Listen on the socket for a client.
  4. Accept a connection from a client.
  5. Receive and send data.
  6. Disconnect.

WinSock2 Client

  1. Initialize Winsock.
  2. Create a socket.
  3. Connect to the server.
  4. Send and receive data.
  5. Disconnect.

This is working fine but no fun. Lets make it working in threads.

Net will be client server communicating with each other in different threads; like read thread and write threads.