Skip to content

Instantly share code, notes, and snippets.

@baslr
Last active August 29, 2015 14:09
Show Gist options
  • Save baslr/35ea7baaf906b9ff4157 to your computer and use it in GitHub Desktop.
Save baslr/35ea7baaf906b9ff4157 to your computer and use it in GitHub Desktop.
test client for EADDRNOTAVAIL
// Generated by CoffeeScript 1.8.0
(function() {
var doReq, http, onRes;
http = require('http');
doReq = function() {
return http.get({
hostname: '127.0.0.1',
port: 60666,
path: '/',
headers: {
Connection: 'Keep-Alive'
}
}, onRes);
};
onRes = function(res) {
var buf;
buf = new Buffer(0);
console.log(res.headers);
res.on('data', function(data) {
return buf = Buffer.concat([buf, data]);
});
return res.on('end', doReq);
};
doReq();
}).call(this);
// Generated by CoffeeScript 1.8.0
(function() {
var http, webServer;
http = require('http');
webServer = http.createServer();
webServer.listen(60666, '0.0.0.0');
webServer.on('request', function(req, res) {
res.setHeader('connection', 'keep-alive');
res.setHeader('Content-Type', 'Content-Type: text/plain; charset=utf-8');
res.setHeader('content-length', 4);
return res.end('test');
});
}).call(this);
@baslr
Copy link
Author

baslr commented Nov 16, 2014

with watch -n 1 "netstat -natp|grep ':60666'" I get

...
tcp        0      0 127.0.0.1:53754         127.0.0.1:60666         TIME_WAIT   -
tcp        0      0 127.0.0.1:49699         127.0.0.1:60666         TIME_WAIT   -
tcp        0      0 127.0.0.1:49630         127.0.0.1:60666         TIME_WAIT   -
tcp        0      0 127.0.0.1:54991         127.0.0.1:60666         TIME_WAIT   -
tcp        0      0 127.0.0.1:49421         127.0.0.1:60666         TIME_WAIT   -
tcp        0      0 127.0.0.1:50014         127.0.0.1:60666         TIME_WAIT   -
tcp        0      0 127.0.0.1:50325         127.0.0.1:60666         TIME_WAIT   -
tcp        0      0 127.0.0.1:48768         127.0.0.1:60666         TIME_WAIT   -
...

Client exits with

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: connect EADDRNOTAVAIL
    at errnoException (net.js:904:11)
    at connect (net.js:766:19)
    at net.js:845:9
    at dns.js:72:18
    at process._tickCallback (node.js:419:13)

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