UNPKG

naked-websocket

Version:

Fastest WebSockets for node to node data exchange.

21 lines (15 loc) 448 B
const nws = require('..'); // use same options as: https://nodejs.org/api/net.html var options = { protocol: 'ws' }; var server = nws.createServer(options, function(socket) { console.log('client connected, socket.headers,', socket.headers); socket.on('data', function(chunk) { console.log(chunk.toString()); }); socket.write('hello client via net socket'); }); server.listen(8080, function() { console.log('server bound'); });