1

When creating a simple server to listen on a UNIX domain socket…

var server = require("net").createServer();
server.listen("/tmp/whatever.sock"); // Listen at UNIX domain socket
server.on("connection", function(stream) {

    // What now?

});

…what uniquely identifies that stream when it hits the "connection"-callback?

When working with WebSockets, I'm used to creating a var clients = {} and storing streams in it by the IP-and-port the connection originated from.

What's the equivalent "IP-and-port" unique identifier for a UNIX-domain socket and how can I see it from Node?

1 Answers1

0

File descriptors are the "IP+port-equivalent" UNIX socket connection identifiers.

A Node stream corresponding to a UNIX socket connection has stream._handle.fd containing that file descriptor.

Community
  • 1
  • 1