Click here to Skip to main content
15,892,537 members
Articles / Web Development / ASP.NET

Web Socket Server

Rate me:
Please Sign up or sign in to vote.
4.76/5 (35 votes)
3 Jun 2010CPOL5 min read 588.1K   38.3K   166  
An example of an implementation of a web socket server and how to interact with it from JavaScript
This archive contains the compiled sources for the WebSocketServer (WebSocketServer.dll) and the WebSocketChatServer (WebSocketChatServer.exe).
Please rename WebSocketChatServer.exe_ to WebSocketChatServer.exe inorder to be able to execute it.

To interact with the server please use the following javascript on a web page running on localhost:8080

if('WebSocket' in window){
  connect('ws://localhost:8181/chat');
}
 
function connect(host) {
  var ws = new WebSocket(host);
  ws.onopen = function () {
    alert('connected');
  };
 
  ws.onmessage = function (evt) {  
    alert('reveived data:'+evt.data);
  };
 
  ws.onclose = function () {
    alert('socket closed');
  };
};

See http://www.codeproject.com/KB/webservices/c_sharp_web_socket_server.aspx to read the full article and to download the source code

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Denmark Denmark
Software Developer in Aalborg, Denmark.

Comments and Discussions