Browse Source

lib: return this from net.Socket.end()

PR-URL: https://github.com/nodejs/node/pull/13481
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
v6
Sam Roberts 8 years ago
parent
commit
324f1115b3
  1. 2
      doc/api/net.md
  2. 2
      lib/net.js
  3. 5
      test/parallel/test-socket-write-after-fin.js

2
doc/api/net.md

@ -648,6 +648,8 @@ server will still send some data.
If `data` is specified, it is equivalent to calling
`socket.write(data, encoding)` followed by [`socket.end()`][].
Returns `socket`.
### socket.localAddress
<!-- YAML
added: v0.9.6

2
lib/net.js

@ -497,6 +497,8 @@ Socket.prototype.end = function(data, encoding) {
this.read(0);
else
maybeDestroy(this);
return this;
};

5
test/parallel/test-socket-write-after-fin.js

@ -2,7 +2,7 @@
const common = require('../common');
const assert = require('assert');
const net = require('net');
const expected = 'hello1hello2hello3\nTHUNDERMUSCLE!';
const expected = 'hello1hello2hello3\nbye';
const server = net.createServer({
allowHalfOpen: true
@ -35,5 +35,6 @@ server.listen(0, common.mustCall(function() {
sock.write('hello1');
sock.write('hello2');
sock.write('hello3\n');
sock.end('THUNDERMUSCLE!');
assert.strictEqual(sock.end('bye'), sock);
}));

Loading…
Cancel
Save