https://github.com/joyent/node/blob/master/lib/net.js#L314