diff --git a/doc/api/net.markdown b/doc/api/net.markdown index ee7e487ca91770..08f27a57a5649d 100644 --- a/doc/api/net.markdown +++ b/doc/api/net.markdown @@ -533,6 +533,11 @@ client connects on `'192.168.1.1'`, the value would be `'192.168.1.1'`. 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`. diff --git a/lib/net.js b/lib/net.js index c3ccebb6423f66..bd64b49ee75773 100644 --- a/lib/net.js +++ b/lib/net.js @@ -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; diff --git a/test/parallel/test-cluster-http-pipe.js b/test/parallel/test-cluster-http-pipe.js index f4ee5c240e6854..0aae9b6b4409bb 100644 --- a/test/parallel/test-cluster-http-pipe.js +++ b/test/parallel/test-cluster-http-pipe.js @@ -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); res.writeHead(200); res.end('OK');