Add 'type' parameter to net.Server.listenFD()

This is needed in case the provided socket is not the default 'tcp4' type
(i.e. and needs different read/write/etc methods). With this patch, one can
call listenFD(sock, 'unix') to bind to existing UNIX domain sockets.
This commit is contained in:
Peter Griess 2010-06-08 18:09:17 -07:00 committed by Ryan Dahl
parent bca16a0581
commit de6d663a67

View File

@ -1167,12 +1167,13 @@ Server.prototype.listen = function () {
} }
}; };
Server.prototype.listenFD = function (fd) { Server.prototype.listenFD = function (fd, type) {
if (this.fd) { if (this.fd) {
throw new Error('Server already opened'); throw new Error('Server already opened');
} }
this.fd = fd; this.fd = fd;
this.type = type || null;
this._startWatcher(); this._startWatcher();
}; };