• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5const net = require('net');
6
7const server = net.createServer(common.mustCall((socket) => {
8  socket.end(Buffer.alloc(1024));
9})).listen(0, common.mustCall(() => {
10  const socket = net.connect(server.address().port);
11  assert.strictEqual(socket.allowHalfOpen, false);
12  socket.resume();
13  socket.on('end', common.mustCall(() => {
14    process.nextTick(() => {
15      // Ensure socket is not destroyed straight away
16      // without proper shutdown.
17      assert(!socket.destroyed);
18      server.close();
19    });
20  }));
21  socket.on('finish', common.mustCall(() => {
22    assert(!socket.destroyed);
23  }));
24  socket.on('close', common.mustCall());
25}));
26