SHARE
TWEET

Untitled

a guest Dec 13th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var net = require('net');
  2. var sockets = [];
  3.  
  4. var server = net.createServer(function (socket) {
  5.     sockets.push(socket);
  6.     socket.on('data', function(d){
  7.         for (var i=0; i < sockets.length; i++){
  8.             if(sockets[i] == socket) continue;
  9.             sockets[i].write(d);
  10.         }
  11.     });
  12.     socket.on('end', function(){
  13.         var i = sockets.indexOf(socket);
  14.         sockets.splice(i, 1);
  15.     });
  16. });
  17.  
  18. server.listen(1337, "127.0.0.1");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top