All Projects → joewalnes → Websocketd

joewalnes / Websocketd

Licence: bsd-2-clause
Turn any program that uses STDIN/STDOUT into a WebSocket server. Like inetd, but for WebSockets.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
Roff
2310 projects

Projects that are alternatives of or similar to Websocketd

Ws Tcp Relay
A simple relay between WebSocket clients and TCP servers
Stars: ✭ 186 (-98.82%)
Mutual labels:  proxy, websockets, websocket-server
Websocat
Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
Stars: ✭ 3,477 (-78.03%)
Mutual labels:  proxy, websockets, websocket-server
Stl.fusion
Get real-time UI updates in Blazor apps and 10-1000x faster API responses with a novel approach to distributed reactive computing. Fusion brings computed observables and automatic dependency tracking from Knockout.js/MobX/Vue to the next level by enabling a single dependency graph span multiple servers and clients, including Blazor apps running in browser.
Stars: ✭ 858 (-94.58%)
Mutual labels:  websockets, websocket-server
Websockets Chat
Laravel WebSockets chat
Stars: ✭ 44 (-99.72%)
Mutual labels:  websockets, websocket-server
Sandstone
PHP microframework designed to build a RestApi working together with a websocket server. Build a real time RestApi!
Stars: ✭ 98 (-99.38%)
Mutual labels:  websockets, websocket-server
Ulfius
Web Framework to build REST APIs, Webservices or any HTTP endpoint in C language. Can stream large amount of data, integrate JSON data with Jansson, and create websocket services
Stars: ✭ 666 (-95.79%)
Mutual labels:  websockets, websocket-server
Cowboy
Small, fast, modern HTTP server for Erlang/OTP.
Stars: ✭ 6,533 (-58.73%)
Mutual labels:  websockets, websocket-server
Arduinowebsockets
arduinoWebSockets
Stars: ✭ 1,265 (-92.01%)
Mutual labels:  websockets, websocket-server
Seasocks
Simple, small, C++ embeddable webserver with WebSockets support
Stars: ✭ 517 (-96.73%)
Mutual labels:  websockets, websocket-server
Websockets
WebSockets Inception
Stars: ✭ 120 (-99.24%)
Mutual labels:  proxy, websockets
Php Wss
Web-socket server/client with multi-process and parse templates support on server and send/receive options on client
Stars: ✭ 117 (-99.26%)
Mutual labels:  websockets, websocket-server
Websocket
WSServer is a fast, configurable, and extendable WebSocket Server for UNIX systems written in C (C11).
Stars: ✭ 144 (-99.09%)
Mutual labels:  websockets, websocket-server
Gwsocket
fast, standalone, language-agnostic WebSocket server RFC6455 compliant
Stars: ✭ 550 (-96.53%)
Mutual labels:  websockets, websocket-server
Awesome Websockets
A curated list of Websocket libraries and resources.
Stars: ✭ 850 (-94.63%)
Mutual labels:  websockets, websocket-server
Rockgo
A developing game server framework,based on Entity Component System(ECS).
Stars: ✭ 532 (-96.64%)
Mutual labels:  websockets, websocket-server
Megalodon
Mastodon, Pleroma and Misskey API client library for node.js and browser
Stars: ✭ 52 (-99.67%)
Mutual labels:  proxy, websockets
Microwebsrv
A micro HTTP Web server that supports WebSockets, html/python language templating and routing handlers, for MicroPython (used on Pycom modules & ESP32)
Stars: ✭ 420 (-97.35%)
Mutual labels:  websockets, websocket-server
Php Websocket
Simple WebSocket server implemented in PHP.
Stars: ✭ 473 (-97.01%)
Mutual labels:  websockets, websocket-server
Facil.io
Your high performance web application C framework
Stars: ✭ 1,393 (-91.2%)
Mutual labels:  websockets, websocket-server
Ixwebsocket
websocket and http client and server library, coming with ws, a command line swiss army knife utility
Stars: ✭ 204 (-98.71%)
Mutual labels:  websockets, websocket-server

websocketd

websocketd is a small command-line tool that will wrap an existing command-line interface program, and allow it to be accessed via a WebSocket.

WebSocket-capable applications can now be built very easily. As long as you can write an executable program that reads STDIN and writes to STDOUT, you can build a WebSocket server. Do it in Python, Ruby, Perl, Bash, .NET, C, Go, PHP, Java, Clojure, Scala, Groovy, Expect, Awk, VBScript, Haskell, Lua, R, whatever! No networking libraries necessary.

-@joewalnes

Details

Upon startup, websocketd will start a WebSocket server on a specified port, and listen for connections.

Upon a connection, it will fork the appropriate process, and disconnect the process when the WebSocket connection closes (and vice-versa).

Any message sent from the WebSocket client will be piped to the process's STDIN stream, followed by a \n newline.

Any text printed by the process to STDOUT shall be sent as a WebSocket message whenever a \n newline is encountered.

Download

If you're on a Mac, you can install websocketd using Homebrew. Just run brew install websocketd. For other operating systems, or if you don't want to use Homebrew, check out the link below.

Download for Linux, OS X and Windows

Quickstart

To get started, we'll create a WebSocket endpoint that will accept connections, then send back messages, counting to 10 with 1 second pause between each one, before disconnecting.

To show how simple it is, let's do it in Bash!

count.sh:

#!/bin/bash
for ((COUNT = 1; COUNT <= 10; COUNT++)); do
  echo $COUNT
  sleep 1
done

Before turning it into a WebSocket server, let's test it from the command line. The beauty of websocketd is that servers work equally well in the command line, or in shell scripts, as they do in the server - with no modifications required.

$ chmod +x count.sh
$ ./count.sh
1
2
3
4
5
6
7
8
9
10

Now let's turn it into a WebSocket server:

$ websocketd --port=8080 ./count.sh

Finally, let's create a web-page to test it.

count.html:

<!DOCTYPE html>
<pre id="log"></pre>
<script>
  // helper function: log message to screen
  function log(msg) {
    document.getElementById('log').textContent += msg + '\n';
  }

  // setup websocket with callbacks
  var ws = new WebSocket('ws://localhost:8080/');
  ws.onopen = function() {
    log('CONNECT');
  };
  ws.onclose = function() {
    log('DISCONNECT');
  };
  ws.onmessage = function(event) {
    log('MESSAGE: ' + event.data);
  };
</script>

Open this page in your web-browser. It will even work if you open it directly from disk using a file:// URL.

More Features

  • Very simple install. Just download the single executable for Linux, Mac or Windows and run it. Minimal dependencies, no installers, no package managers, no external libraries. Suitable for development and production servers.
  • Server side scripts can access details about the WebSocket HTTP request (e.g. remote host, query parameters, cookies, path, etc) via standard CGI environment variables.
  • As well as serving websocket daemons it also includes a static file server and classic CGI server for convenience.
  • Command line help available via websocketd --help.
  • Includes WebSocket developer console to make it easy to test your scripts before you've built a JavaScript frontend.
  • Examples in many programming languages are available to help you getting started.

User Manual

More documentation in the user manual

Example Projects

Got more examples? Open a pull request.

My Other Projects

And follow @joewalnes!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].