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.
33 lines
667 B
33 lines
667 B
'use strict';
|
|
const common = require('../common');
|
|
const net = require('net');
|
|
|
|
const server = net.createServer(common.mustCall(function(stream) {
|
|
stream.setTimeout(100);
|
|
|
|
stream.resume();
|
|
|
|
stream.on('timeout', common.mustCall(function() {
|
|
console.log('timeout');
|
|
// try to reset the timeout.
|
|
stream.write('WHAT.');
|
|
}));
|
|
|
|
stream.on('end', function() {
|
|
console.log('server side end');
|
|
stream.end();
|
|
});
|
|
}));
|
|
|
|
server.listen(0, function() {
|
|
const c = net.createConnection(this.address().port);
|
|
|
|
c.on('data', function() {
|
|
c.end();
|
|
});
|
|
|
|
c.on('end', function() {
|
|
console.log('client side end');
|
|
server.close();
|
|
});
|
|
});
|
|
|