Browse Source

net listen should emit eaddrinuse error

v0.7.4-release
Johan Euphrosine 14 years ago
committed by Ryan Dahl
parent
commit
5d400cfd3a
  1. 7
      lib/net.js
  2. 14
      test/simple/test-net-eaddrinuse.js

7
lib/net.js

@ -1189,10 +1189,13 @@ Server.prototype._startWatcher = function () {
}; };
Server.prototype._doListen = function () { Server.prototype._doListen = function () {
try {
listen(this.fd, this._backlog || 128); listen(this.fd, this._backlog || 128);
this._startWatcher(); this._startWatcher();
}; } catch (err) {
this.emit('error', err);
}
}
Server.prototype.address = function () { Server.prototype.address = function () {

14
test/simple/test-net-eaddrinuse.js

@ -0,0 +1,14 @@
common = require('../common');
assert = common.assert
net = require('net');
var server1 = net.createServer(function (socket) {
});
var server2 = net.createServer(function (socket) {
});
server1.listen(31337);
server2.addListener('error', function(error) {
assert.equal(true, error.message.indexOf('EADDRINUSE') >= 0);
server1.close();
});
server2.listen(31337);
Loading…
Cancel
Save