node-websocketd
✓ Published0🌍 Public
Aalessioalex
Last edited Dec 9, 2013
Created on Dec 9, 2013
This example demonstrates a lightweight Node.js port of the websocketd tool, which exposes a command-line script over a WebSocket connection. It shows how a spawned child process can receive input from and send output to a connected browser client in real time. The implementation uses the `ws` Server to handle WebSocket connections, `websocket-stream` to create a duplex stream over the socket, and `child_process.spawn` to execute the user-supplied command. Standard input and output are piped between the stream and the spawned process, with the process being killed when the stream ends.
AI-generated descriptionnode-websocketd
A lightweight node port of websocketd, originally written in go.
Usage
node-websocketd --port=8080 ./count.sh