Advanced Winsock sample app using secure socket extensions
Secure TCP client and server sample app
A more advanced Winsock sample app that demonstrates the use of secure socket extensions is available in the Windows-classic-samples GitHub repo. The sample includes a TCP client and server that connect securely using the Winsock and the secure socket extensions.
The sample code is split into separate directories as described below:
- stcpclient. The folder that contains the secure TCP client code.
- stcpcommon. The folder that contains common library code that is shared between the secure TCP client and server.
- stcpserver. The folder that contains the secure TCP server code.
The samples are meant to be run on two different computers running Windows Vista or later. Additionally, IPsec credentials must be provisioned on both the computers for the connection to succeed, because the sample uses IPsec for securing its traffic. Please refer to the documentation on IPsec Configuration for more information on setting up IPsec credentials.
Building the sample will generate two executable files:
stcpclient.exe and stcpserver.exe.
Copy stcpclient.exe to computer A and copy stcpserver.exe to computer B. On computer B, start the TCP server by executing the following in a Command Prompt:
stcpserver.exe
Execute the following command for more usage options for the server:
stcpserver.exe /?
Then on computer A, start the TCP client by executing the following in a Command Prompt:
stcpclient.exe <fully-qualified-DNS-name-for-machine-B>
At this point the connection should get established securely.
Execute the following command for more usage options for the client:
stcpclient.exe /?