/tcpws

A WebSocket-TCP proxy server

Primary LanguageHaskellBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Connect to raw TCP using WebSockets!

Run:

    $ tcpws 0.0.0.0 3000

Then, in your Javascript:

    var ws = new WebSocket("ws://localhost:3000/www.twilio.com/80");
    ws.onmessage = function(e) { console.log(e.data) };
    ws.send("GET / HTTP/1.1\r\nHost: www.twilio.com\r\n\r\n")

Usage

The WebSocket server receives URLs in the format /{hostname}/{port}. If I want to connect my WebSocket to www.twilio.com on port 80, I use /www.twilio.com/80:

    new WebSocket("ws://.../www.twilio.com/80");