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.

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

2011-06-25
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.

 2011-07-06

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.

 

2011-07-07

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

http://www.codeproject.com/KB/IP/DeadlocksWebSockets.aspx

 

 

Learn more about HTML5 and Websockets here:

http://html5labs.interoperabilitybridges.com/prototypes/websockets/websockets/info

http://stackoverflow.com/questions/4262543/what-are-good-resources-for-learning-html-5-websockets

Last edited Jul 7, 2011 at 11:46 PM by TWebster, version 16