Click here to Skip to main content
12,628,919 members (34,624 online)
Click here to Skip to main content

Stats

382K views
32.8K downloads
157 bookmarked
Posted

Web Socket Server

, 3 Jun 2010 CPOL
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)

Share

About the Author

jonlist
Denmark Denmark
Software Developer in Aalborg, Denmark.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161205.3 | Last Updated 3 Jun 2010
Article Copyright 2010 by jonlist
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid