11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst net = require('net'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci{ 71cb0ef41Sopenharmony_ci const server = net.createServer(); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci server.listen(common.mustCall(() => { 101cb0ef41Sopenharmony_ci const port = server.address().port; 111cb0ef41Sopenharmony_ci const client = net.connect({ port }, common.mustCall(() => { 121cb0ef41Sopenharmony_ci client.on('error', common.mustCall((err) => { 131cb0ef41Sopenharmony_ci server.close(); 141cb0ef41Sopenharmony_ci assert.strictEqual(err.constructor, Error); 151cb0ef41Sopenharmony_ci assert.strictEqual(err.message, 'write EBADF'); 161cb0ef41Sopenharmony_ci })); 171cb0ef41Sopenharmony_ci client._handle.close(); 181cb0ef41Sopenharmony_ci client.write('foo'); 191cb0ef41Sopenharmony_ci })); 201cb0ef41Sopenharmony_ci })); 211cb0ef41Sopenharmony_ci} 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci{ 241cb0ef41Sopenharmony_ci const server = net.createServer(); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci server.listen(common.mustCall(() => { 271cb0ef41Sopenharmony_ci const port = server.address().port; 281cb0ef41Sopenharmony_ci const client = net.connect({ port }, common.mustCall(() => { 291cb0ef41Sopenharmony_ci client.on('error', common.expectsError({ 301cb0ef41Sopenharmony_ci code: 'ERR_SOCKET_CLOSED', 311cb0ef41Sopenharmony_ci message: 'Socket is closed', 321cb0ef41Sopenharmony_ci name: 'Error' 331cb0ef41Sopenharmony_ci })); 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci server.close(); 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci client._handle.close(); 381cb0ef41Sopenharmony_ci client._handle = null; 391cb0ef41Sopenharmony_ci client.write('foo'); 401cb0ef41Sopenharmony_ci })); 411cb0ef41Sopenharmony_ci })); 421cb0ef41Sopenharmony_ci} 43