Connecting to an already established UNIX socket with node.js?

The method you're looking for is net.createConnection(path):

var client = net.createConnection("/tmp/mysocket");

client.on("connect", function() {
    ... do something when you connect ...
});

client.on("data", function(data) {
    ... do stuff with the data ...
});

I was just trying to get this to work with Linux's abstract sockets and found them to be incompatible with node's net library. Instead, the following code can be used with the abstract-socket library:

const abstract_socket = require('abstract-socket');

let client = abstract_socket.connect('\0my_abstract_socket');

client.on("connect", function() {
    ... do something when you connect ...
});

client.on("data", function(data) {
    ... do stuff with the data ...
});