@ -587,19 +587,27 @@ Socket.prototype._getpeername = function() {
return this . _ peername ;
return this . _ peername ;
} ;
} ;
Socket . prototype . __ defineGetter__ ( 'bytesRead' , function ( ) {
function protoGetter ( name , callback ) {
Object . defineProperty ( Socket . prototype , name , {
configurable : false ,
enumerable : true ,
get : callback
} ) ;
}
protoGetter ( 'bytesRead' , function bytesRead ( ) {
return this . _ handle ? this . _ handle . bytesRead : this [ BYTES_READ ] ;
return this . _ handle ? this . _ handle . bytesRead : this [ BYTES_READ ] ;
} ) ;
} ) ;
Socket . prototype . __ defineGetter__ ( 'remoteAddress' , function ( ) {
protoGetter ( 'remoteAddress' , function remoteAddress ( ) {
return this . _ getpeername ( ) . address ;
return this . _ getpeername ( ) . address ;
} ) ;
} ) ;
Socket . prototype . __ defineGetter__ ( 'remoteFamily' , function ( ) {
protoGetter ( 'remoteFamily' , function remoteFamily ( ) {
return this . _ getpeername ( ) . family ;
return this . _ getpeername ( ) . family ;
} ) ;
} ) ;
Socket . prototype . __ define Getter__ ( 'remotePort' , function ( ) {
protoGetter ( 'remotePort' , function remotePort ( ) {
return this . _ getpeername ( ) . port ;
return this . _ getpeername ( ) . port ;
} ) ;
} ) ;
@ -618,12 +626,12 @@ Socket.prototype._getsockname = function() {
} ;
} ;
Socket . prototype . __ define Getter__ ( 'localAddress' , function ( ) {
protoGetter ( 'localAddress' , function localAddress ( ) {
return this . _ getsockname ( ) . address ;
return this . _ getsockname ( ) . address ;
} ) ;
} ) ;
Socket . prototype . __ define Getter__ ( 'localPort' , function ( ) {
protoGetter ( 'localPort' , function localPort ( ) {
return this . _ getsockname ( ) . port ;
return this . _ getsockname ( ) . port ;
} ) ;
} ) ;
@ -735,7 +743,7 @@ function createWriteReq(req, handle, data, encoding) {
}
}
Socket . prototype . __ define Getter__ ( 'bytesWritten' , function ( ) {
protoGetter ( 'bytesWritten' , function bytesWritte n ( ) {
var bytes = this . _ bytesDispatched ;
var bytes = this . _ bytesDispatched ;
const state = this . _ writableState ;
const state = this . _ writableState ;
const data = this . _ pendingData ;
const data = this . _ pendingData ;