G2A Many GEOs
SHARE
TWEET

Untitled

a guest Mar 30th, 2020 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const net = require('net');
  2. const port = 7070;
  3. const host = '127.0.0.1';
  4.  
  5. 'use strict';
  6.  
  7. sockets=[]
  8.  
  9. const server = net.createServer();
  10. server.listen(port, host, () => {
  11.     console.log('TCP Server is running on port ' + port + '.');
  12. });
  13.  
  14. server.on('connection', (sock) => {
  15.     console.log('CONNECTED: ' + sock.remoteAddress + ':' + sock.remotePort);
  16.     sockets.push(sock);
  17.  
  18.     sock.on('data', (data) => {
  19.         console.log('DATA ' + sock.remoteAddress + ': ' + data.toString());
  20.        
  21.     });
  22.  
  23.     sock.on('close', (data) => {
  24.         let index = sockets.findIndex(function(o) {
  25.             return o.remoteAddress === sock.remoteAddress && o.remotePort === sock.remotePort;
  26.         })
  27.         if (index !== -1) sockets.splice(index, 1);
  28.         console.log('CLOSED: ' + sock.remoteAddress + ' ' + sock.remotePort);
  29.     });
  30. });
RAW Paste Data
Ledger Nano X - The secure hardware wallet
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