add net.Server.listenFD
Now that FD passing is in master, it'd be great to be able to use a received socket (which has already had bind(2) and listen(2) called on it) to fire up a new net.Server instance. This patch adds a net.Server.listenFD() method which will start up the accept watcher on the provided FD.
This commit is contained in:
parent
9be6c501ec
commit
a0134ff0f8
17
lib/net.js
17
lib/net.js
@ -1167,11 +1167,24 @@ Server.prototype.listen = function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Server.prototype._doListen = function () {
|
Server.prototype.listenFD = function (fd) {
|
||||||
listen(this.fd, 128);
|
if (this.fd) {
|
||||||
|
throw new Error('Server already opened');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fd = fd;
|
||||||
|
this._startWatcher();
|
||||||
|
};
|
||||||
|
|
||||||
|
Server.prototype._startWatcher = function () {
|
||||||
this.watcher.set(this.fd, true, false);
|
this.watcher.set(this.fd, true, false);
|
||||||
this.watcher.start();
|
this.watcher.start();
|
||||||
this.emit("listening");
|
this.emit("listening");
|
||||||
|
};
|
||||||
|
|
||||||
|
Server.prototype._doListen = function () {
|
||||||
|
listen(this.fd, 128);
|
||||||
|
this._startWatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user