File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change 2121
2222'use strict' ;
2323const common = require ( '../common' ) ;
24+
2425const net = require ( 'net' ) ;
2526
27+ let serverSocket ;
28+
2629const server = net . createServer ( common . mustCall ( function ( socket ) {
30+ serverSocket = socket ;
31+
2732 socket . resume ( ) ;
2833
2934 socket . on ( 'error' , common . mustCall ( function ( error ) {
30- console . error ( 'got error, closing server' , error ) ;
35+ console . error ( 'received error as expected , closing server' , error ) ;
3136 server . close ( ) ;
3237 } ) ) ;
33-
34- setTimeout ( common . mustCall ( function ( ) {
35- console . error ( 'about to try to write' ) ;
36- socket . write ( 'test' , common . mustCall ( ) ) ;
37- } ) , 250 ) ;
3838} ) ) ;
3939
4040server . listen ( 0 , function ( ) {
4141 const client = net . connect ( this . address ( ) . port , function ( ) {
42+ // cliend.end() will close both the readable and writable side
43+ // of the duplex because allowHalfOpen defaults to false.
44+ // Then 'end' will be emitted when it receives a FIN packet from
45+ // the other side.
46+ client . on ( 'end' , common . mustCall ( ( ) => {
47+ serverSocket . write ( 'test' , common . mustCall ( ) ) ;
48+ } ) ) ;
4249 client . end ( ) ;
4350 } ) ;
4451} ) ;
You can’t perform that action at this time.
0 commit comments