11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst net = require('net'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst server = net.createServer(); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciserver.on('connection', (socket) => { 101cb0ef41Sopenharmony_ci let endEmitted = false; 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci socket.once('readable', () => { 131cb0ef41Sopenharmony_ci setTimeout(() => { 141cb0ef41Sopenharmony_ci socket.read(); 151cb0ef41Sopenharmony_ci }, common.platformTimeout(100)); 161cb0ef41Sopenharmony_ci }); 171cb0ef41Sopenharmony_ci socket.on('end', () => { 181cb0ef41Sopenharmony_ci endEmitted = true; 191cb0ef41Sopenharmony_ci }); 201cb0ef41Sopenharmony_ci socket.on('close', () => { 211cb0ef41Sopenharmony_ci assert(endEmitted); 221cb0ef41Sopenharmony_ci server.close(); 231cb0ef41Sopenharmony_ci }); 241cb0ef41Sopenharmony_ci socket.end('foo'); 251cb0ef41Sopenharmony_ci}); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ciserver.listen(common.mustCall(() => { 281cb0ef41Sopenharmony_ci const socket = net.createConnection(server.address().port, () => { 291cb0ef41Sopenharmony_ci socket.end('foo'); 301cb0ef41Sopenharmony_ci }); 311cb0ef41Sopenharmony_ci})); 32