What is the connection identifier when creating the TCP server?

I use node.js to create a TCP server and every connection will be permanent. It is known that node.js is one process, how to talk about all the connections. Is there something like a connection identifier?

+4
source share
2 answers

you can create it yourself

var net = require('net'); var connects_count = 0; var server = net.createServer(function (socket) { socket.connectionId = connects_count; connects_count++; socket.write("Echo server\r\n"); socket.pipe(socket); }); server.listen(1337, "127.0.0.1"); 
+5
source

All Articles