net: ensure Socket reported address is current
authorRyan Graham <r.m.graham@gmail.com>
Thu, 2 Jul 2015 22:26:21 +0000 (15:26 -0700)
committerSam Roberts <vieuxtech@gmail.com>
Thu, 6 Aug 2015 17:45:59 +0000 (10:45 -0700)
commit5d2acfb8e5d00549152995ee671ff168d5c00e38
tree72f8b9ab98077654f112b63835dc6ebec2bdbeb6
parent67987d9d83517e8d812f13dc5e9eca1d1b9d21ac
net: ensure Socket reported address is current

Any time the connection state or the underlying handle itself changes,
the socket's name (aka, local address) can change.

To deal with this we need to reset the cached sockname any time we
set or unset the internal handle or an existing handle establishes a
connection.

PR-URL: https://github.com/nodejs/io.js/pull/2095
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
lib/net.js
test/parallel/test-net-socket-local-address.js [new file with mode: 0644]