~yolanda.robla/ubuntu/trusty/nodejs/add_distribution

« back to all changes in this revision

Viewing changes to test/simple/test-net-reconnect.js

  • Committer: Package Import Robot
  • Author(s): Jérémy Lal
  • Date: 2013-08-14 00:16:46 UTC
  • mfrom: (7.1.40 sid)
  • Revision ID: package-import@ubuntu.com-20130814001646-bzlysfh8sd6mukbo
Tags: 0.10.15~dfsg1-4
* Update 2005 patch, adding a handful of tests that can fail on
  slow platforms.
* Add 1004 patch to fix test failures when writing NaN to buffer
  on mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
var disconnect_count = 0;
31
31
 
32
32
var server = net.createServer(function(socket) {
33
 
  socket.on('connect', function() {
34
 
    socket.write('hello\r\n');
35
 
  });
 
33
  console.error('SERVER: got socket connection');
 
34
  socket.resume();
 
35
 
 
36
  console.error('SERVER connect, writing');
 
37
  socket.write('hello\r\n');
36
38
 
37
39
  socket.on('end', function() {
 
40
    console.error('SERVER socket end, calling end()');
38
41
    socket.end();
39
42
  });
40
43
 
41
44
  socket.on('close', function(had_error) {
42
 
    //console.log('server had_error: ' + JSON.stringify(had_error));
 
45
    console.log('SERVER had_error: ' + JSON.stringify(had_error));
43
46
    assert.equal(false, had_error);
44
47
  });
45
48
});
46
49
 
47
50
server.listen(common.PORT, function() {
48
 
  console.log('listening');
 
51
  console.log('SERVER listening');
49
52
  var client = net.createConnection(common.PORT);
50
53
 
51
54
  client.setEncoding('UTF8');
52
55
 
53
56
  client.on('connect', function() {
54
 
    console.log('client connected.');
 
57
    console.error('CLIENT connected', client._writableState);
55
58
  });
56
59
 
57
60
  client.on('data', function(chunk) {
58
61
    client_recv_count += 1;
59
62
    console.log('client_recv_count ' + client_recv_count);
60
63
    assert.equal('hello\r\n', chunk);
 
64
    console.error('CLIENT: calling end', client._writableState);
61
65
    client.end();
62
66
  });
63
67
 
 
68
  client.on('end', function() {
 
69
    console.error('CLIENT end');
 
70
  });
 
71
 
64
72
  client.on('close', function(had_error) {
65
 
    console.log('disconnect');
 
73
    console.log('CLIENT disconnect');
66
74
    assert.equal(false, had_error);
67
75
    if (disconnect_count++ < N)
68
76
      client.connect(common.PORT); // reconnect