Cannot bind to IPv6 address

Posted by ereOn on Stack Overflow See other posts from Stack Overflow or by ereOn
Published on 2010-03-27T11:49:24Z Indexed on 2010/03/27 11:53 UTC
Read the original article Hit count: 187

Filed under:
|
|

I am facing a strange problem on my Ubuntu Karmic system.

When I call getaddrinfo() with AI_PASSIVE and AF_UNSPEC, for an empty host and the UDP 12000 port to get a bindable address, I only get back one IPv4 result (0.0.0.0:12000 for instance).

If I change my call and specify AF_INET6 instead of AF_UNSPEC, then getaddrinfo() returns "Name or service not known".

Shouldn't I get [::]:12000 as a result ?

The same thing happens if I set the host to ::1.

When I call getaddrinfo() without AI_PASSIVE (to get a "connectable" address) for the host "localhost" and the UDP 12000 port, I first get [::1]:12000 then 127.0.0.1:12000.

So apparently, my system is IPv6 ready (I can ping to both IPv4 and IPv6 addresses, as well as DNS resolution). But how is it that I can't get an IPv6 address to bind to with getaddrinfo() ?

Do you guys have any idea about what could be wrong ?

My OS is Ubuntu Karmic, fresh install without any networking tweaking.

Thank you.

© Stack Overflow or respective owner

Related posts about IPv6

Related posts about bind