Skip to content
Closed
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Socket.prototype.bind = function(port /*, address, callback*/) {
if (port instanceof UDP) {
replaceHandle(self, port);
startListening(self);
return;
return self;
}

var address;
Expand Down Expand Up @@ -231,6 +231,8 @@ Socket.prototype.bind = function(port /*, address, callback*/) {
startListening(self);
}
});

return self;
};


Expand Down Expand Up @@ -356,6 +358,8 @@ Socket.prototype.close = function() {
this._handle.close();
this._handle = null;
this.emit('close');

return this;
};


Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-dgram-bind.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ socket.on('listening', function () {
socket.close();
});

socket.bind(); // should not throw
var result = socket.bind(); // should not throw

assert.strictEqual(result, socket); // should have returned itself
2 changes: 1 addition & 1 deletion test/parallel/test-dgram-close.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ buf.fill(42);
var socket = dgram.createSocket('udp4');
var handle = socket._handle;
socket.send(buf, 0, buf.length, common.PORT, 'localhost');
socket.close();
assert.strictEqual(socket.close(), socket);
socket = null;

// Verify that accessing handle after closure doesn't throw
Expand Down