joyent/node — pull request #6083 by floatdrop (2013-08-20 13:39:30+00:00)
Title: net: provide family option in net.connect and net.createConnection

There is issue with [```dns.lookup```](https://github.com/joyent/node/blob/master/lib/net.js#L861) in ```net``` module. If lookup fails with IPv4 [this code](https://github.com/joyent/node/blob/master/lib/net.js#L870-L877) will throw an error and there is no way to specify another stack version to fix this. In general it will throw ENETUNREACH error when IPv4 address is not available, but IPv6 address is.

This patch appends ```family``` option to specify stack verison in ```net.connect``` and ```net.createConnection``` options. With this options programmers can write ```http.Agent``` with overridden [```createSocket```](https://github.com/joyent/node/blob/master/lib/_http_agent.js#L179) which will catch ENETUNREACH and retry with another stack version.