@@ -119,7 +119,7 @@ const BYTES_READ = Symbol('bytesRead');
119119function Socket ( options ) {
120120 if ( ! ( this instanceof Socket ) ) return new Socket ( options ) ;
121121
122- this . _connecting = false ;
122+ this . connecting = false ;
123123 this . _hadError = false ;
124124 this . _handle = null ;
125125 this . _parent = null ;
@@ -202,7 +202,7 @@ Socket.prototype._unrefTimer = function unrefTimer() {
202202// so that only the writable side will be cleaned up.
203203function onSocketFinish ( ) {
204204 // If still connecting - defer handling 'finish' until 'connect' will happen
205- if ( this . _connecting ) {
205+ if ( this . connecting ) {
206206 debug ( 'osF: not yet connected' ) ;
207207 return this . once ( 'connect' , onSocketFinish ) ;
208208 }
@@ -367,9 +367,16 @@ Socket.prototype.address = function() {
367367} ;
368368
369369
370+ Object . defineProperty ( Socket . prototype , '_connecting' , {
371+ get : function ( ) {
372+ return this . connecting ;
373+ }
374+ } ) ;
375+
376+
370377Object . defineProperty ( Socket . prototype , 'readyState' , {
371378 get : function ( ) {
372- if ( this . _connecting ) {
379+ if ( this . connecting ) {
373380 return 'opening' ;
374381 } else if ( this . readable && this . writable ) {
375382 return 'open' ;
@@ -397,7 +404,7 @@ Object.defineProperty(Socket.prototype, 'bufferSize', {
397404Socket . prototype . _read = function ( n ) {
398405 debug ( '_read' ) ;
399406
400- if ( this . _connecting || ! this . _handle ) {
407+ if ( this . connecting || ! this . _handle ) {
401408 debug ( '_read wait for connection' ) ;
402409 this . once ( 'connect' , ( ) => this . _read ( n ) ) ;
403410 } else if ( ! this . _handle . reading ) {
@@ -430,7 +437,7 @@ function maybeDestroy(socket) {
430437 if ( ! socket . readable &&
431438 ! socket . writable &&
432439 ! socket . destroyed &&
433- ! socket . _connecting &&
440+ ! socket . connecting &&
434441 ! socket . _writableState . length ) {
435442 socket . destroy ( ) ;
436443 }
@@ -465,7 +472,7 @@ Socket.prototype._destroy = function(exception, cb) {
465472 return ;
466473 }
467474
468- this . _connecting = false ;
475+ this . connecting = false ;
469476
470477 this . readable = this . writable = false ;
471478
@@ -648,7 +655,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
648655 // If we are still connecting, then buffer this for later.
649656 // The Writable logic will buffer up any more writes while
650657 // waiting for this one to be done.
651- if ( this . _connecting ) {
658+ if ( this . connecting ) {
652659 this . _pendingData = data ;
653660 this . _pendingEncoding = encoding ;
654661 this . once ( 'connect' , function ( ) {
@@ -803,7 +810,7 @@ function connect(self, address, port, addressType, localAddress, localPort) {
803810 // TODO return promise from Socket.prototype.connect which
804811 // wraps _connectReq.
805812
806- assert . ok ( self . _connecting ) ;
813+ assert . ok ( self . connecting ) ;
807814
808815 var err ;
809816
@@ -913,7 +920,7 @@ Socket.prototype.connect = function(options, cb) {
913920
914921 this . _unrefTimer ( ) ;
915922
916- this . _connecting = true ;
923+ this . connecting = true ;
917924 this . writable = true ;
918925
919926 if ( pipe ) {
@@ -952,7 +959,7 @@ function lookupAndConnect(self, options) {
952959 var addressType = exports . isIP ( host ) ;
953960 if ( addressType ) {
954961 process . nextTick ( function ( ) {
955- if ( self . _connecting )
962+ if ( self . connecting )
956963 connect ( self , host , port , addressType , localAddress , localPort ) ;
957964 } ) ;
958965 return ;
@@ -980,7 +987,7 @@ function lookupAndConnect(self, options) {
980987 // It's possible we were destroyed while looking this up.
981988 // XXX it would be great if we could cancel the promise returned by
982989 // the look up.
983- if ( ! self . _connecting ) return ;
990+ if ( ! self . connecting ) return ;
984991
985992 if ( err ) {
986993 // net.createConnection() creates a net.Socket object and
@@ -1048,8 +1055,8 @@ function afterConnect(status, handle, req, readable, writable) {
10481055
10491056 debug ( 'afterConnect' ) ;
10501057
1051- assert . ok ( self . _connecting ) ;
1052- self . _connecting = false ;
1058+ assert . ok ( self . connecting ) ;
1059+ self . connecting = false ;
10531060 self . _sockname = null ;
10541061
10551062 if ( status == 0 ) {
@@ -1065,7 +1072,7 @@ function afterConnect(status, handle, req, readable, writable) {
10651072 self . read ( 0 ) ;
10661073
10671074 } else {
1068- self . _connecting = false ;
1075+ self . connecting = false ;
10691076 var details ;
10701077 if ( req . localAddress && req . localPort ) {
10711078 details = req . localAddress + ':' + req . localPort ;
0 commit comments