Skip to content

Commit 537dc1a

Browse files
daeyeonyichoi
authored andcommitted
Add a return value of net.Server.listen for method chaining (#998)
IoT.js-DCO-1.0-Signed-off-by: Daeyeon Jeong [email protected]
1 parent e58dc5d commit 537dc1a

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

docs/api/IoT.js-API-Net.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ server.close();
247247
* `host` {string} Host the client should connect to.
248248
* `backlog` {number} The maximum length of the queue of pending connections. **Default:** `511`.
249249
* `listenListener` {Function} Listener for the `'listening'` event.
250+
* Returns: {Object} The self instance of `net.Server`.
250251

251252
Begin accepting connections on the specified port and hostname.
252253
If the hostname is omitted, the server will accept connections on any IPv4 address (0.0.0.0).

src/js/net.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ Server.prototype.listen = function() {
523523
self.emit('listening');
524524
}
525525
});
526+
527+
return this;
526528
};
527529

528530

test/run_pass/test_net_connect.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ var server = net.createServer({
2525
function(socket) {
2626
server.close();
2727
}
28-
);
29-
30-
server.listen(port);
28+
).listen(port);
3129

3230
server.on('connection', function(socket) {
3331
var data = '';

0 commit comments

Comments
 (0)