lib,src: add unix socket getsockname/getpeername

The implementation is a minor API change in that socket.address() now
returns a `{ address: '/path/to/socket' }` object, like it does for TCP
and UDP sockets.  Before this commit, it returned `socket._pipeName`,
which is a string when present.

Change common.PIPE on Windows from '\\\\.\\pipe\\libuv-test' to
'\\\\?\\pipe\\libuv-test'.  Windows converts the '.' to a '?' when
creating a named pipe, meaning that common.PIPE didn't match the
result from NtQueryInformationFile().

Fixes: https://github.com/nodejs/node/issues/954
PR-URL: https://github.com/nodejs/node/pull/956
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
Ben Noordhuis 2015-02-25 17:19:11 +01:00
parent a43af39ffc
commit f337595441
8 changed files with 56 additions and 15 deletions

View file

@ -9,6 +9,7 @@ var headers_ok = false;
var body_ok = false;
var server = http.createServer(function(req, res) {
assert.equal(req.socket.address().address, common.PIPE);
res.writeHead(200, {
'Content-Type': 'text/plain',
'Connection': 'close'
@ -19,6 +20,7 @@ var server = http.createServer(function(req, res) {
});
server.listen(common.PIPE, function() {
assert.equal(server.address().address, common.PIPE);
var options = {
socketPath: common.PIPE,