Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Probably it's an encoding issue. Here's a working C# server I wrote:</p> <pre><code>class Program { static void Main(string[] args) { var listener = new TcpListener(IPAddress.Loopback, 8181); listener.Start(); using (var client = listener.AcceptTcpClient()) using (var stream = client.GetStream()) using (var reader = new StreamReader(stream)) using (var writer = new StreamWriter(stream)) { writer.WriteLine("HTTP/1.1 101 Web Socket Protocol Handshake"); writer.WriteLine("Upgrade: WebSocket"); writer.WriteLine("Connection: Upgrade"); writer.WriteLine("WebSocket-Origin: http://localhost:8080"); writer.WriteLine("WebSocket-Location: ws://localhost:8181/websession"); writer.WriteLine(""); } listener.Stop(); } } </code></pre> <p>And the corresponding client hosted on <code>localhost:8080</code>:</p> <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; var socket = new WebSocket('ws://localhost:8181/websession'); socket.onopen = function() { alert('handshake successfully established. May send data now...'); }; socket.onclose = function() { alert('connection closed'); }; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This example only establishes the handshake. You will need to tweak the server in order to continue accepting data once the handshake has been established.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload