1 // This tests setTimeout() by having multiple clients connecting and sending
2 // data in random intervals. Clients are also randomly disconnecting until there
3 // are no more clients left. If no false timeout occurs, this test has passed.
4 var common = require('../common'),
5 assert = require('assert'),
6 http = require('http'),
7 server = http.createServer(),
10 server.on('request', function(req, res) {
11 req.socket.setTimeout(1000);
12 req.socket.on('timeout', function() {
13 throw new Error('Unexpected timeout');
15 req.on('end', function() {
19 if (connections == 0) {
26 server.listen(common.PORT, '127.0.0.1', function() {
27 for (var i = 0; i < 10; i++) {
30 setTimeout(function() {
31 var request = http.request({
38 var nextPing = (Math.random() * 900).toFixed();
43 request.write('ping');
44 setTimeout(ping, nextPing);