Skip to content
Browse files
lib: add net.Socket#localFamily property
Complements the existing net.Socket#remoteFamily property.

PR-URL: #956
Reviewed-By: Sam Roberts <>
Reviewed-By: Trevor Norris <>
  • Loading branch information
bnoordhuis committed Aug 27, 2015
1 parent f337595 commit 7a999a13766ac68049812fedbdfd15a0250f0f07
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
@@ -533,6 +533,11 @@ client connects on `''`, the value would be `''`.
For UNIX sockets and Windows pipes, the file path the socket is listening
on. The local address for client sockets is always `''`, the empty string.

### socket.localFamily

The string representation of the local IP family. `'IPv4'` or `'IPv6'`
for TCP sockets, `'pipe'` for UNIX sockets and Windows pipes.

### socket.localPort

The numeric representation of the local port. For example, `80` or `21`.
@@ -606,6 +606,9 @@ Socket.prototype.__defineGetter__('localAddress', function() {
return this._getsockname().address;

Socket.prototype.__defineGetter__('localFamily', function() {
return this._getsockname().family;

Socket.prototype.__defineGetter__('localPort', function() {
return this._getsockname().port;
@@ -33,6 +33,7 @@ http.createServer(function(req, res) {
assert.equal(req.connection.remoteFamily, 'pipe');
assert.equal(req.connection.remotePort, undefined);
assert.equal(req.connection.localAddress, common.PIPE);
assert.equal(req.connection.localFamily, 'pipe');
assert.equal(req.connection.localPort, undefined);

0 comments on commit 7a999a1

Please sign in to comment.