FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

dgram: return self on .bind() and .close() by brendanashworth · Pull Request #214 · nodejs/node · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 5 additions & 1 deletion lib/dgram.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL