1'use strict'; 2const common = require('../common'); 3 4const assert = require('assert'); 5const net = require('net'); 6 7const server = net.createServer(); 8 9server.on('connection', (socket) => { 10 let endEmitted = false; 11 12 socket.once('readable', () => { 13 setTimeout(() => { 14 socket.read(); 15 }, common.platformTimeout(100)); 16 }); 17 socket.on('end', () => { 18 endEmitted = true; 19 }); 20 socket.on('close', () => { 21 assert(endEmitted); 22 server.close(); 23 }); 24 socket.end('foo'); 25}); 26 27server.listen(common.mustCall(() => { 28 const socket = net.createConnection(server.address().port, () => { 29 socket.end('foo'); 30 }); 31})); 32