mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
627 B
25 lines
627 B
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
const server = net.createServer(function(socket) {
|
|
socket.pipe(socket);
|
|
}).listen(0, common.mustCall(function() {
|
|
const conn = net.connect(this.address().port);
|
|
let 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');
|
|
}));
|
|
}));
|
|
|