mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
7a0e462f9f
Manually fix issues that eslint --fix couldn't do automatically. PR-URL: https://github.com/nodejs/node/pull/10685 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
40 lines
938 B
JavaScript
40 lines
938 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
const expected = 'hello1hello2hello3\nTHUNDERMUSCLE!';
|
|
|
|
const server = net.createServer({
|
|
allowHalfOpen: true
|
|
}, common.mustCall(function(sock) {
|
|
let serverData = '';
|
|
|
|
sock.setEncoding('utf8');
|
|
sock.on('data', function(c) {
|
|
serverData += c;
|
|
});
|
|
sock.on('end', common.mustCall(function() {
|
|
assert.strictEqual(serverData, expected);
|
|
sock.end(serverData);
|
|
server.close();
|
|
}));
|
|
}));
|
|
server.listen(0, common.mustCall(function() {
|
|
const sock = net.connect(this.address().port);
|
|
let clientData = '';
|
|
|
|
sock.setEncoding('utf8');
|
|
sock.on('data', function(c) {
|
|
clientData += c;
|
|
});
|
|
|
|
sock.on('end', common.mustCall(function() {
|
|
assert.strictEqual(clientData, expected);
|
|
}));
|
|
|
|
sock.write('hello1');
|
|
sock.write('hello2');
|
|
sock.write('hello3\n');
|
|
sock.end('THUNDERMUSCLE!');
|
|
}));
|