@@ -585,19 +585,27 @@ Socket.prototype._getpeername = function() { |
585 | 585 | return this._peername; |
586 | 586 | }; |
587 | 587 |
|
588 | | -Socket.prototype.__defineGetter__('bytesRead', function() { |
| 588 | +function protoGetter(name, callback) { |
| 589 | + Object.defineProperty(Socket.prototype, name, { |
| 590 | + configurable: false, |
| 591 | + enumerable: true, |
| 592 | + get: callback |
| 593 | + }); |
| 594 | +} |
| 595 | + |
| 596 | +protoGetter('bytesRead', function bytesRead() { |
589 | 597 | return this._handle ? this._handle.bytesRead : this[BYTES_READ]; |
590 | 598 | }); |
591 | 599 |
|
592 | | -Socket.prototype.__defineGetter__('remoteAddress', function() { |
| 600 | +protoGetter('remoteAddress', function remoteAddress() { |
593 | 601 | return this._getpeername().address; |
594 | 602 | }); |
595 | 603 |
|
596 | | -Socket.prototype.__defineGetter__('remoteFamily', function() { |
| 604 | +protoGetter('remoteFamily', function remoteFamily() { |
597 | 605 | return this._getpeername().family; |
598 | 606 | }); |
599 | 607 |
|
600 | | -Socket.prototype.__defineGetter__('remotePort', function() { |
| 608 | +protoGetter('remotePort', function remotePort() { |
601 | 609 | return this._getpeername().port; |
602 | 610 | }); |
603 | 611 |
|
@@ -616,12 +624,12 @@ Socket.prototype._getsockname = function() { |
616 | 624 | }; |
617 | 625 |
|
618 | 626 |
|
619 | | -Socket.prototype.__defineGetter__('localAddress', function() { |
| 627 | +protoGetter('localAddress', function localAddress() { |
620 | 628 | return this._getsockname().address; |
621 | 629 | }); |
622 | 630 |
|
623 | 631 |
|
624 | | -Socket.prototype.__defineGetter__('localPort', function() { |
| 632 | +protoGetter('localPort', function localPort() { |
625 | 633 | return this._getsockname().port; |
626 | 634 | }); |
627 | 635 |
|
@@ -733,7 +741,7 @@ function createWriteReq(req, handle, data, encoding) { |
733 | 741 | } |
734 | 742 |
|
735 | 743 |
|
736 | | -Socket.prototype.__defineGetter__('bytesWritten', function() { |
| 744 | +protoGetter('bytesWritten', function bytesWritten() { |
737 | 745 | var bytes = this._bytesDispatched; |
738 | 746 | const state = this._writableState; |
739 | 747 | const data = this._pendingData; |
|