Skip to content

Instantly share code, notes, and snippets.

@yosefd
Created June 27, 2012 11:49
Show Gist options
  • Save yosefd/3003574 to your computer and use it in GitHub Desktop.
Save yosefd/3003574 to your computer and use it in GitHub Desktop.
http over named pipe sample
var http = require('http');
var port = '\\\\.\\pipe\\nameofthepipe';
http.createServer(function (req, res) {
console.info('request received');
res.end('gotyou');
}).listen(port);
console.info('listening on:', port);
var opt = {
host: 'localhost',
port: port,
method: 'GET'
}
var req = http.request(opt, function(res) {
console.info('STATUS:', res.statusCode);
res.on('data', function(chunk) {
console.info('BODY:', chunk.toString());
});
});
req.on('error', function(e) {
console.error('request failed:', e);
});
req.end();
@yosefd
Copy link
Author

yosefd commented Jun 27, 2012

On 0.6.19 the output:

listening on: \\.\pipe\nameofthepipe
request received
STATUS: 200
BODY: gotyou

on 0.8.0 the output:

listening on: \\.\pipe\nameofthepipe
request failed: { [Error: connect EADDRNOTAVAIL]
  code: 'EADDRNOTAVAIL',
  errno: 'EADDRNOTAVAIL',
  syscall: 'connect' }

@fatso83
Copy link

fatso83 commented Oct 13, 2015

so this no longer works with Node 4? If it did, it would be a life saver on Azure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment