This project is read-only.

Project Description
A simple websockets server built in C++ with the CRT, "windows.h", and Winsock. No CLR or MFC is used.

For learning purposes.

Added a very simple HTTP GET request client in C/C++, built using winsock. See httpclient.h.
As described on blog.

Added a simple HTTP server that can accept multiple, concurrent client connections. Displays the entire raw HTTP request header. Useful for debugging applications e.g. .NET apps that use HttpWebRequest, or any client app. that makes HTTP requests.


The program now demonstrates reproducible race condition and deadlock scenarios. The websocket client is run in a browser and sends the server a message, then asserts that the message echoed back from the serer is equal to the one sent. The program is contained within the new, added files:

  • websockets-server-race-conditions+deadlock.cpp: will create a deadlock if a client browser instance opens a socket then stops sending messages. This is because the server thread servicing that websocket is blocking on the call to recv and has acquired the mutex, blocking all other server threads.
  • websockets-server-race-conditions.cpp: the mutex can be disabled, and if it is, the websocket client receives a message not equal to the one sent.
  • websockets-client.html

 Instructions to run:

  1. run the websocket server program (e.g. websockets-server-race-conditions.cpp) in Visual Studio, then once the server is listening,
  2. run multiple websockets client by opening websockets-client.html in many instances of Firefox or Chrome.



This project is more fully explained by my article on CodeProject:



Learn more about HTML5 and Websockets here:

Last edited Jul 8, 2011 at 12:46 AM by TWebster, version 16