I'm coming late to this party, but I wanted to post what I found for anyone else having this problem.
The curl error is related to this bug
http://curl.haxx.se/mail/tracker-2010-12/0008.html, basically curl is trying to bind an ipv6 address on an ipv4 interface. My first thought was to add the curl ipv4 option to the script, but it seems that this option is missing in PHP 5.2
https://bugs.php.net/bug.php?id=47739. What worked for me, since I was running the DNS forwarder anyway, was to add just the ipv4 address for dns.he.net to the host overrides in the DNS forwarder. You should be able to accomplish the same thing by adding this to your hosts file but I haven't tested that.