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