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
619 B

'use strict';
const common = require('../common');
var assert = require('assert');
var 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');
}));
}));