mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 10:27:05 +00:00

PR-URL: https://github.com/nodejs/node/pull/10550 Reviewed-By: Rich Trott <rtrott@gmail.com>
26 lines
623 B
JavaScript
26 lines
623 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
var server = net.createServer(function(socket) {
|
|
socket.pipe(socket);
|
|
}).listen(0, common.mustCall(function() {
|
|
var conn = net.connect(this.address().port);
|
|
var received = '';
|
|
|
|
conn.setEncoding('utf8');
|
|
conn.write('before');
|
|
conn.on('connect', function() {
|
|
conn.write('after');
|
|
});
|
|
conn.on('data', function(buf) {
|
|
received += buf;
|
|
conn.end();
|
|
});
|
|
conn.on('end', common.mustCall(function() {
|
|
server.close();
|
|
assert.strictEqual(received, 'before' + 'after');
|
|
}));
|
|
}));
|