Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-net-connect-options.js « parallel « test - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e794c40859856a0878e70c7087f6e9d2b8ca1d69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
const common = require('../common');
const assert = require('assert');
const net = require('net');

const server = net.createServer({
  allowHalfOpen: true
}, common.mustCall(function(socket) {
  socket.resume();
  socket.on('end', common.mustCall(function() {}));
  socket.end();
}));

server.listen(0, function() {
  const client = net.connect({
    host: '127.0.0.1',
    port: this.address().port,
    allowHalfOpen: true
  }, common.mustCall(function() {
    console.error('client connect cb');
    client.resume();
    client.on('end', common.mustCall(function() {
      setTimeout(function() {
        assert(client.writable);
        client.end();
      }, 10);
    }));
    client.on('close', function() {
      server.close();
    });
  }));
});