@@ -118,7 +118,7 @@ const BYTES_READ = Symbol('bytesRead');
118118function Socket ( options ) {
119119 if ( ! ( this instanceof Socket ) ) return new Socket ( options ) ;
120120
121- this . _connecting = false ;
121+ this . connecting = false ;
122122 this . _hadError = false ;
123123 this . _handle = null ;
124124 this . _parent = null ;
@@ -201,7 +201,7 @@ Socket.prototype._unrefTimer = function unrefTimer() {
201201// so that only the writable side will be cleaned up.
202202function onSocketFinish ( ) {
203203 // If still connecting - defer handling 'finish' until 'connect' will happen
204- if ( this . _connecting ) {
204+ if ( this . connecting ) {
205205 debug ( 'osF: not yet connected' ) ;
206206 return this . once ( 'connect' , onSocketFinish ) ;
207207 }
@@ -366,9 +366,16 @@ Socket.prototype.address = function() {
366366} ;
367367
368368
369+ Object . defineProperty ( Socket . prototype , '_connecting' , {
370+ get : function ( ) {
371+ return this . connecting ;
372+ }
373+ } ) ;
374+
375+
369376Object . defineProperty ( Socket . prototype , 'readyState' , {
370377 get : function ( ) {
371- if ( this . _connecting ) {
378+ if ( this . connecting ) {
372379 return 'opening' ;
373380 } else if ( this . readable && this . writable ) {
374381 return 'open' ;
@@ -396,7 +403,7 @@ Object.defineProperty(Socket.prototype, 'bufferSize', {
396403Socket . prototype . _read = function ( n ) {
397404 debug ( '_read' ) ;
398405
399- if ( this . _connecting || ! this . _handle ) {
406+ if ( this . connecting || ! this . _handle ) {
400407 debug ( '_read wait for connection' ) ;
401408 this . once ( 'connect' , ( ) => this . _read ( n ) ) ;
402409 } else if ( ! this . _handle . reading ) {
@@ -429,7 +436,7 @@ function maybeDestroy(socket) {
429436 if ( ! socket . readable &&
430437 ! socket . writable &&
431438 ! socket . destroyed &&
432- ! socket . _connecting &&
439+ ! socket . connecting &&
433440 ! socket . _writableState . length ) {
434441 socket . destroy ( ) ;
435442 }
@@ -466,7 +473,7 @@ Socket.prototype._destroy = function(exception, cb) {
466473 return ;
467474 }
468475
469- self . _connecting = false ;
476+ this . connecting = false ;
470477
471478 this . readable = this . writable = false ;
472479
@@ -647,7 +654,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
647654 // If we are still connecting, then buffer this for later.
648655 // The Writable logic will buffer up any more writes while
649656 // waiting for this one to be done.
650- if ( this . _connecting ) {
657+ if ( this . connecting ) {
651658 this . _pendingData = data ;
652659 this . _pendingEncoding = encoding ;
653660 this . once ( 'connect' , function ( ) {
@@ -802,7 +809,7 @@ function connect(self, address, port, addressType, localAddress, localPort) {
802809 // TODO return promise from Socket.prototype.connect which
803810 // wraps _connectReq.
804811
805- assert . ok ( self . _connecting ) ;
812+ assert . ok ( self . connecting ) ;
806813
807814 var err ;
808815
@@ -912,7 +919,7 @@ Socket.prototype.connect = function(options, cb) {
912919
913920 this . _unrefTimer ( ) ;
914921
915- this . _connecting = true ;
922+ this . connecting = true ;
916923 this . writable = true ;
917924
918925 if ( pipe ) {
@@ -949,7 +956,7 @@ function lookupAndConnect(self, options) {
949956 var addressType = exports . isIP ( host ) ;
950957 if ( addressType ) {
951958 process . nextTick ( function ( ) {
952- if ( self . _connecting )
959+ if ( self . connecting )
953960 connect ( self , host , port , addressType , localAddress , localPort ) ;
954961 } ) ;
955962 return ;
@@ -984,7 +991,7 @@ function lookupAndConnect(self, options) {
984991 // It's possible we were destroyed while looking this up.
985992 // XXX it would be great if we could cancel the promise returned by
986993 // the look up.
987- if ( ! self . _connecting ) return ;
994+ if ( ! self . connecting ) return ;
988995
989996 if ( err ) {
990997 // net.createConnection() creates a net.Socket object and
@@ -1052,8 +1059,8 @@ function afterConnect(status, handle, req, readable, writable) {
10521059
10531060 debug ( 'afterConnect' ) ;
10541061
1055- assert . ok ( self . _connecting ) ;
1056- self . _connecting = false ;
1062+ assert . ok ( self . connecting ) ;
1063+ self . connecting = false ;
10571064 self . _sockname = null ;
10581065
10591066 if ( status == 0 ) {
@@ -1069,7 +1076,7 @@ function afterConnect(status, handle, req, readable, writable) {
10691076 self . read ( 0 ) ;
10701077
10711078 } else {
1072- self . _connecting = false ;
1079+ self . connecting = false ;
10731080 var details ;
10741081 if ( req . localAddress && req . localPort ) {
10751082 details = req . localAddress + ':' + req . localPort ;
0 commit comments