@@ -118,7 +118,7 @@ const BYTES_READ = Symbol('bytesRead');
118
118
function Socket ( options ) {
119
119
if ( ! ( this instanceof Socket ) ) return new Socket ( options ) ;
120
120
121
- this . _connecting = false ;
121
+ this . connecting = false ;
122
122
this . _hadError = false ;
123
123
this . _handle = null ;
124
124
this . _parent = null ;
@@ -201,7 +201,7 @@ Socket.prototype._unrefTimer = function unrefTimer() {
201
201
// so that only the writable side will be cleaned up.
202
202
function onSocketFinish ( ) {
203
203
// If still connecting - defer handling 'finish' until 'connect' will happen
204
- if ( this . _connecting ) {
204
+ if ( this . connecting ) {
205
205
debug ( 'osF: not yet connected' ) ;
206
206
return this . once ( 'connect' , onSocketFinish ) ;
207
207
}
@@ -366,9 +366,16 @@ Socket.prototype.address = function() {
366
366
} ;
367
367
368
368
369
+ Object . defineProperty ( Socket . prototype , '_connecting' , {
370
+ get : function ( ) {
371
+ return this . connecting ;
372
+ }
373
+ } ) ;
374
+
375
+
369
376
Object . defineProperty ( Socket . prototype , 'readyState' , {
370
377
get : function ( ) {
371
- if ( this . _connecting ) {
378
+ if ( this . connecting ) {
372
379
return 'opening' ;
373
380
} else if ( this . readable && this . writable ) {
374
381
return 'open' ;
@@ -396,7 +403,7 @@ Object.defineProperty(Socket.prototype, 'bufferSize', {
396
403
Socket . prototype . _read = function ( n ) {
397
404
debug ( '_read' ) ;
398
405
399
- if ( this . _connecting || ! this . _handle ) {
406
+ if ( this . connecting || ! this . _handle ) {
400
407
debug ( '_read wait for connection' ) ;
401
408
this . once ( 'connect' , ( ) => this . _read ( n ) ) ;
402
409
} else if ( ! this . _handle . reading ) {
@@ -429,7 +436,7 @@ function maybeDestroy(socket) {
429
436
if ( ! socket . readable &&
430
437
! socket . writable &&
431
438
! socket . destroyed &&
432
- ! socket . _connecting &&
439
+ ! socket . connecting &&
433
440
! socket . _writableState . length ) {
434
441
socket . destroy ( ) ;
435
442
}
@@ -466,7 +473,7 @@ Socket.prototype._destroy = function(exception, cb) {
466
473
return ;
467
474
}
468
475
469
- self . _connecting = false ;
476
+ this . connecting = false ;
470
477
471
478
this . readable = this . writable = false ;
472
479
@@ -647,7 +654,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
647
654
// If we are still connecting, then buffer this for later.
648
655
// The Writable logic will buffer up any more writes while
649
656
// waiting for this one to be done.
650
- if ( this . _connecting ) {
657
+ if ( this . connecting ) {
651
658
this . _pendingData = data ;
652
659
this . _pendingEncoding = encoding ;
653
660
this . once ( 'connect' , function ( ) {
@@ -802,7 +809,7 @@ function connect(self, address, port, addressType, localAddress, localPort) {
802
809
// TODO return promise from Socket.prototype.connect which
803
810
// wraps _connectReq.
804
811
805
- assert . ok ( self . _connecting ) ;
812
+ assert . ok ( self . connecting ) ;
806
813
807
814
var err ;
808
815
@@ -912,7 +919,7 @@ Socket.prototype.connect = function(options, cb) {
912
919
913
920
this . _unrefTimer ( ) ;
914
921
915
- this . _connecting = true ;
922
+ this . connecting = true ;
916
923
this . writable = true ;
917
924
918
925
if ( pipe ) {
@@ -949,7 +956,7 @@ function lookupAndConnect(self, options) {
949
956
var addressType = exports . isIP ( host ) ;
950
957
if ( addressType ) {
951
958
process . nextTick ( function ( ) {
952
- if ( self . _connecting )
959
+ if ( self . connecting )
953
960
connect ( self , host , port , addressType , localAddress , localPort ) ;
954
961
} ) ;
955
962
return ;
@@ -984,7 +991,7 @@ function lookupAndConnect(self, options) {
984
991
// It's possible we were destroyed while looking this up.
985
992
// XXX it would be great if we could cancel the promise returned by
986
993
// the look up.
987
- if ( ! self . _connecting ) return ;
994
+ if ( ! self . connecting ) return ;
988
995
989
996
if ( err ) {
990
997
// net.createConnection() creates a net.Socket object and
@@ -1052,8 +1059,8 @@ function afterConnect(status, handle, req, readable, writable) {
1052
1059
1053
1060
debug ( 'afterConnect' ) ;
1054
1061
1055
- assert . ok ( self . _connecting ) ;
1056
- self . _connecting = false ;
1062
+ assert . ok ( self . connecting ) ;
1063
+ self . connecting = false ;
1057
1064
self . _sockname = null ;
1058
1065
1059
1066
if ( status == 0 ) {
@@ -1069,7 +1076,7 @@ function afterConnect(status, handle, req, readable, writable) {
1069
1076
self . read ( 0 ) ;
1070
1077
1071
1078
} else {
1072
- self . _connecting = false ;
1079
+ self . connecting = false ;
1073
1080
var details ;
1074
1081
if ( req . localAddress && req . localPort ) {
1075
1082
details = req . localAddress + ':' + req . localPort ;
0 commit comments