GeezerVison is showing github.com — lib: return this from net.Socket.end() · nodejs/node@063c4fa
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/net.md +2Lines changed: 2 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -575,6 +575,8 @@ server will still send some data. |
575 | 575 | If `data` is specified, it is equivalent to calling |
576 | 576 | `socket.write(data, encoding)` followed by `socket.end()`. |
577 | 577 |
|
| 578 | +Returns `socket`. |
| 579 | + |
578 | 580 | ### socket.localAddress |
579 | 581 | <!-- YAML |
580 | 582 | added: v0.9.6 |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/net.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -444,6 +444,8 @@ Socket.prototype.end = function(data, encoding) { |
444 | 444 | this.read(0); |
445 | 445 | else |
446 | 446 | maybeDestroy(this); |
| 447 | + |
| 448 | + return this; |
447 | 449 | }; |
448 | 450 |
|
449 | 451 |
|
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-socket-write-after-fin.js +3-2Lines changed: 3 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
2 | 2 | const common = require('../common'); |
3 | 3 | const assert = require('assert'); |
4 | 4 | const net = require('net'); |
5 | | -const expected = 'hello1hello2hello3\nTHUNDERMUSCLE!'; |
| 5 | +const expected = 'hello1hello2hello3\nbye'; |
6 | 6 |
|
7 | 7 | const server = net.createServer({ |
8 | 8 | allowHalfOpen: true |
@@ -35,5 +35,6 @@ server.listen(0, common.mustCall(function() { |
35 | 35 | sock.write('hello1'); |
36 | 36 | sock.write('hello2'); |
37 | 37 | sock.write('hello3\n'); |
38 | | - sock.end('THUNDERMUSCLE!'); |
| 38 | + assert.strictEqual(sock.end('bye'), sock); |
| 39 | + |
39 | 40 | })); |