{"id":13393669,"url":"https://github.com/joewalnes/websocketd","last_synced_at":"2025-05-12T13:11:29.299Z","repository":{"id":6949414,"uuid":"8201256","full_name":"joewalnes/websocketd","owner":"joewalnes","description":"Turn any program that uses STDIN/STDOUT into a WebSocket server. Like inetd, but for WebSockets. ","archived":false,"fork":false,"pushed_at":"2024-06-10T21:38:01.000Z","size":1073,"stargazers_count":17213,"open_issues_count":56,"forks_count":1015,"subscribers_count":368,"default_branch":"master","last_synced_at":"2025-04-23T13:03:34.330Z","etag":null,"topics":["proxy","websocket-server","websockets"],"latest_commit_sha":null,"homepage":"http://websocketd.com/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joewalnes.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-02-14T14:52:55.000Z","updated_at":"2025-04-23T07:53:02.000Z","dependencies_parsed_at":"2024-01-06T00:58:27.870Z","dependency_job_id":"3fae28dd-3ac4-4fd8-a66e-d35cd1e3411e","html_url":"https://github.com/joewalnes/websocketd","commit_stats":{"total_commits":236,"total_committers":55,"mean_commits":4.290909090909091,"dds":0.7923728813559322,"last_synced_commit":"8d6da30045855d1d9d81fd8a0936ef84981764f0"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joewalnes%2Fwebsocketd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joewalnes%2Fwebsocketd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joewalnes%2Fwebsocketd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joewalnes%2Fwebsocketd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joewalnes","download_url":"https://codeload.github.com/joewalnes/websocketd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745170,"owners_count":21957318,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["proxy","websocket-server","websockets"],"created_at":"2024-07-30T17:00:58.418Z","updated_at":"2025-05-12T13:11:28.970Z","avatar_url":"https://github.com/joewalnes.png","language":"Go","funding_links":[],"categories":["Go","开源类库","Tools","Go (134)","开发运维工具","Open source library","proxy","Programming Languages","Network","Command-Line Interface (CLI) Tools","High level","Maths"],"sub_categories":["WebSocket","Go","NetServices","Protocols and APIs","Bitwise operations"],"readme":"websocketd\n==========\n\n`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.\n\nWebSocket-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.\n\n-[@joewalnes](https://twitter.com/joewalnes)\n\nDetails\n-------\n\nUpon startup, `websocketd` will start a WebSocket server on a specified port, and listen for connections.\n\nUpon a connection, it will fork the appropriate process, and disconnect the process when the WebSocket connection closes (and vice-versa).\n\nAny message sent from the WebSocket client will be piped to the process's `STDIN` stream, followed by a `\\n` newline.\n\nAny text printed by the process to `STDOUT` shall be sent as a WebSocket message whenever a `\\n` newline is encountered.\n\n\nDownload\n--------\n\nIf you're on a Mac, you can install `websocketd` using [Homebrew](http://brew.sh/). Just run `brew install websocketd`. For other operating systems, or if you don't want to use Homebrew, check out the link below.\n\n**[Download for Linux, OS X and Windows](https://github.com/joewalnes/websocketd/wiki/Download-and-install)**\n\n\nQuickstart\n----------\n\nTo 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.\n\nTo show how simple it is, let's do it in Bash!\n\n__count.sh__:\n\n```sh\n#!/bin/bash\nfor ((COUNT = 1; COUNT \u003c= 10; COUNT++)); do\n  echo $COUNT\n  sleep 1\ndone\n```\n\nBefore 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.\n\n```sh\n$ chmod +x count.sh\n$ ./count.sh\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n```\n\nNow let's turn it into a WebSocket server:\n\n```sh\n$ websocketd --port=8080 ./count.sh\n```\n\nFinally, let's create a web-page to test it.\n\n__count.html__:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003cpre id=\"log\"\u003e\u003c/pre\u003e\n\u003cscript\u003e\n  // helper function: log message to screen\n  function log(msg) {\n    document.getElementById('log').textContent += msg + '\\n';\n  }\n\n  // setup websocket with callbacks\n  var ws = new WebSocket('ws://localhost:8080/');\n  ws.onopen = function() {\n    log('CONNECT');\n  };\n  ws.onclose = function() {\n    log('DISCONNECT');\n  };\n  ws.onmessage = function(event) {\n    log('MESSAGE: ' + event.data);\n  };\n\u003c/script\u003e\n```\nOpen this page in your web-browser. It will even work if you open it directly\nfrom disk using a `file://` URL.\n\nMore Features\n-------------\n\n*   Very simple install. Just [download](https://github.com/joewalnes/websocketd/wiki/Download-and-install) 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.\n*   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](https://github.com/joewalnes/websocketd/wiki/Environment-variables).\n*   As well as serving websocket daemons it also includes a static file server and classic CGI server for convenience.\n*   Command line help available via `websocketd --help`.\n*   Includes [WebSocket developer console](https://github.com/joewalnes/websocketd/wiki/Developer-console) to make it easy to test your scripts before you've built a JavaScript frontend.\n*   [Examples in many programming languages](https://github.com/joewalnes/websocketd/tree/master/examples) are available to help you getting started.\n\nUser Manual\n-----------\n\n**[More documentation in the user manual](https://github.com/joewalnes/websocketd/wiki)**\n\nExample Projects\n----------------\n\n*   [Plot real time Linux CPU/IO/Mem stats to a HTML5 dashboard using websocketd and vmstat](https://github.com/joewalnes/web-vmstats) _(for Linux)_\n*   [Arbitrary REPL in the browser using websocketd](https://github.com/rowanthorpe/ws-repl)\n*   [Retrieve SQL data from server with LiveCode and webSocketd](https://github.com/samansjukur/wslc)\n*   [List files from a configured folder](https://github.com/dbalakirev/directator) _(for Linux)_\n*   [Listen for gamepad events and report them to the system](https://github.com/experiment322/controlloid-server) _(this + android = gamepad emulator)_\n\nGot more examples? Open a pull request.\n\nMy Other Projects\n-----------------\n\n*   [ReconnectingWebSocket](https://github.com/joewalnes/reconnecting-websocket) - Simplest way to add some robustness to your WebSocket connections.\n*   [Smoothie Charts](http://smoothiecharts.org/) - JavaScript charts for streaming data.\n*   Visit [The Igloo Lab](http://theigloolab.com/) to see and subscribe to other thingies I make.\n\nAnd [follow @joewalnes](https://twitter.com/joewalnes)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoewalnes%2Fwebsocketd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoewalnes%2Fwebsocketd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoewalnes%2Fwebsocketd/lists"}