diff options
author | James Hight <james@zavoo.com> | 2012-12-31 21:01:42 -0500 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-01-05 17:05:13 +0100 |
commit | 3f76419a04da48b92b50b51450685b8565886200 (patch) | |
tree | bd54345f89f9e8399e48fca0d6bdab93bdb29305 /lib/net.js | |
parent | 5664dd2fc1e872a850c2891ee11f86e98b69106d (diff) | |
download | android-node-v8-3f76419a04da48b92b50b51450685b8565886200.tar.gz android-node-v8-3f76419a04da48b92b50b51450685b8565886200.tar.bz2 android-node-v8-3f76419a04da48b92b50b51450685b8565886200.zip |
net: add localAddress and localPort to Socket
Diffstat (limited to 'lib/net.js')
-rw-r--r-- | lib/net.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/net.js b/lib/net.js index fc56918eba..a347c08507 100644 --- a/lib/net.js +++ b/lib/net.js @@ -526,6 +526,30 @@ Socket.prototype.__defineGetter__('remotePort', function() { }); +Socket.prototype._getsockname = function() { + if (!this._handle || !this._handle.getsockname) { + return {}; + } + if (!this._sockname) { + this._sockname = this._handle.getsockname(); + if (this._sockname === null) { + return {}; + } + } + return this._sockname; +}; + + +Socket.prototype.__defineGetter__('localAddress', function() { + return this._getsockname().address; +}); + + +Socket.prototype.__defineGetter__('localPort', function() { + return this._getsockname().port; +}); + + Socket.prototype.write = function(chunk, encoding, cb) { if (typeof chunk !== 'string' && !Buffer.isBuffer(chunk)) throw new TypeError('invalid data'); |