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

test-net-write-after-close.js « parallel « test - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0a1dcd98b2b3c71a37e5b217d639946c42913162 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';
const common = require('../common');
const net = require('net');

const server = net.createServer(common.mustCall(function(socket) {
  socket.resume();

  socket.on('error', common.mustCall(function(error) {
    console.error('got error, closing server', error);
    server.close();
  }));

  setTimeout(common.mustCall(function() {
    console.error('about to try to write');
    socket.write('test', common.mustCall(function(e) {}));
  }), 250);
}));

server.listen(0, function() {
  const client = net.connect(this.address().port, function() {
    client.end();
  });
});