Skip to content

Instantly share code, notes, and snippets.

@ry
Created May 21, 2010 00:37
Show Gist options
  • Save ry/408328 to your computer and use it in GitHub Desktop.
Save ry/408328 to your computer and use it in GitHub Desktop.
require('../common');
sys = require('sys');
net = require('net');
gotConnect = false;
gotClose = false;
server = net.createServer(function (s) {
s.destroy();
server.close();
});
server.listen(9090);
server.addListener('listening', function ( ) {
var connection = net.createConnection(9090);
connection.addListener('connect', function () {
gotConnect = true;
sys.debug('connect event');
});
connection.addListener('close', function () {
gotClose = true;
sys.debug('connect event');
});
});
process.addListener('exit', function () {
assert.ok(gotConnect);
assert.ok(gotClose);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment