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.
42 lines
922 B
42 lines
922 B
13 years ago
|
var common = require('../common');
|
||
|
var assert = require('assert');
|
||
|
var net = require('net');
|
||
|
|
||
|
var serverGotEnd = false;
|
||
|
var clientGotEnd = false;
|
||
|
|
||
|
var server = net.createServer({allowHalfOpen: true}, function(socket) {
|
||
12 years ago
|
socket.resume();
|
||
13 years ago
|
socket.on('end', function() {
|
||
|
serverGotEnd = true;
|
||
|
});
|
||
|
socket.end();
|
||
|
});
|
||
|
|
||
|
server.listen(common.PORT, function() {
|
||
|
var client = net.connect({
|
||
|
host: '127.0.0.1',
|
||
|
port: common.PORT,
|
||
|
allowHalfOpen: true
|
||
|
}, function() {
|
||
12 years ago
|
console.error('client connect cb');
|
||
|
client.resume();
|
||
13 years ago
|
client.on('end', function() {
|
||
|
clientGotEnd = true;
|
||
|
setTimeout(function() {
|
||
|
assert(client.writable);
|
||
|
client.end();
|
||
|
}, 10);
|
||
|
});
|
||
|
client.on('close', function() {
|
||
|
server.close();
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
|
||
|
process.on('exit', function() {
|
||
12 years ago
|
console.error('exit', serverGotEnd, clientGotEnd);
|
||
13 years ago
|
assert(serverGotEnd);
|
||
|
assert(clientGotEnd);
|
||
|
});
|