Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,14 @@ var Client = exports.Client = function Client (port, host, options) {

this.connectionsMade = 0;

// Setup the TCP connection
var stream = this.stream = net.createConnection(this.port = port, this.host = host);
if (port === 0) {
// Assume UNIX socket, take host as path to socket file
this.port = port;
var stream = this.stream = net.createConnection(this.host = host);
} else {
// Regular TCP socket, setup the TCP connection
var stream = this.stream = net.createConnection(this.port = port, this.host = host);
}

stream.on("data", this.handleData.bind(this));
// currReply = null;
Expand Down Expand Up @@ -336,7 +342,11 @@ Client.prototype.attemptReconnect = function () {
client = this;
this.reconnectionTimer = setTimeout( function () {
client.emit("reconnecting", client);
stream.connect(client.port, client.host);
if (client.port === 0) { // UNIX socket
stream.connect(client.host);
} else { // TCP socket
stream.connect(client.port, client.host);
}
}, delay);
};

Expand Down