File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -21,11 +21,11 @@ export default class TcpServer extends TcpSocket {
2121
2222 listen ( port , host , callback ) {
2323 host = host || '0.0.0.0' ;
24- const listenEvent = this . _eventEmitter . addListener ( 'listening' , ( ) => {
25- this . _eventEmitter . removeSubscription ( listenEvent ) ;
26- if ( callback ) callback ( ) ;
24+ const connectListener = this . _eventEmitter . addListener ( 'connect' , ( ev ) => {
25+ if ( this . _id !== ev . id ) return ;
26+ connectListener . remove ( ) ;
27+ if ( callback ) callback ( ev . address ) ;
2728 } ) ;
28-
2929 this . _registerEvents ( ) ;
3030 this . _eventEmitter . addListener ( 'connection' , ( ev ) => {
3131 if ( this . _id !== ev . id ) return ;
Original file line number Diff line number Diff line change @@ -53,9 +53,10 @@ export default class TcpSocket {
5353 options . localPort = Number ( options . localPort ) || 0 ;
5454 options . localAddress = options . localAddress || '0.0.0.0' ;
5555 options . interface = options . interface || '' ;
56- const connectListener = this . _eventEmitter . addListener ( 'connect' , ( address ) => {
56+ const connectListener = this . _eventEmitter . addListener ( 'connect' , ( ev ) => {
57+ if ( this . _id !== ev . id ) return ;
5758 connectListener . remove ( ) ;
58- if ( callback ) callback ( address ) ;
59+ if ( callback ) callback ( ev . address ) ;
5960 } ) ;
6061 if ( options . timeout ) this . setTimeout ( options . timeout ) ;
6162 else if ( this . _timeout ) this . _activeTimer ( this . _timeout . msecs ) ;
You can’t perform that action at this time.
0 commit comments