https://github.com/creationix/websocket
A simple drop-in replacement for node's TCP server that supports the WebSocket protocol.
https://github.com/creationix/websocket
Last synced: about 1 year ago
JSON representation
A simple drop-in replacement for node's TCP server that supports the WebSocket protocol.
- Host: GitHub
- URL: https://github.com/creationix/websocket
- Owner: creationix
- Created: 2009-12-31T16:32:35.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2010-04-24T04:31:37.000Z (about 16 years ago)
- Last Synced: 2025-03-24T04:14:38.352Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 97.7 KB
- Stars: 26
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# WebSocket Server
`websocket` is a simple wrapper around tcp.createServer that abstracts away the details of a browser WebSocket. It's designed to be a drop in replacement for a regular TCP server, but be accessible from a browser that supports WebSocket.
var websocket = require("websocket");
var server = websocket.createServer(function (socket) {
socket.write("hello\r\n");
socket.addListener("data", function (data) {
socket.write(data);
});
socket.addListener("end", function () {
socket.write("goodbye\r\n");
socket.end();
});
});
server.listen(7000, "localhost");
This implementation is quick and dirty and skips over a lot of details. For example it doesn't validate any of the same origin stuff.
For a more fleshed out implementation, but with a larger api, please see