[plt-scheme] IPv6?

From: Johan Liseborn (johan at liseborn.se)
Date: Fri Nov 4 04:43:27 EST 2005

On Nov 3, 2005, at 23:04, Lee Begg wrote:

> On Fri, 04 Nov 2005 10:41, Matthew Flatt wrote:
>>
>>  * If you system supports IPv6, beware that "localhost" is probably
>>    mapped to an IPv6 address by default. In that case, if you're  
>> trying
>>    to contact an IPv4 server, it probably won't work; use "127.0.0.1"
>>    instead.
>
> All the computers I have dealt with use ip6-localhost for the IPv6  
> loopback,
> so localhost remains IPv4 only.

Hmm, both my main OS:es seems to do it differently. Darwin 8.3.0  
seems to map 'localhost' to both '127.0.0.1' and '::1' (in that  
order), while OpenBSD (3.5 in this case) also maps 'localhost' to  
both v4 and v6, but in the opposite order from Darwin. SuSE Linux  
also seems to map 'localhost' to both v4 and v6.


> The C API for connecting (and listening) have changed slightly, and  
> it is now
> expected that the program will loop through the addresses provided  
> by name
> lookup until it successfully connects.  So if localhost maps to  
> ipv4 and
> ipv6, there shouldn't be a problem.

Yes, but doesn't the order of binding become important then? I.e. if  
you happen to bind 'localhost' to *both' v4 and v6, the order of the  
result-set from getaddrinfo will impact the type of socket you get?

Personally, I tend to consider the "ordering-problem" as a  
"configuration-problem" though. This means that if I *really* want to  
use e.g. the IPv6 loopback address, I say '::1' rather than  
'localhost'; I say '127.0.0.1' if I want the IPv4 equivalent. If I  
*really* wanted to use the names rather than the numeric addresses, I  
would have to make sure the address bindings where setup accordingly  
(e.g. in /etc/hosts).

Taking this approach, I think getaddrinfo and "looping approach"  
seems to work well. The only thing I can see becoming a bit  
problematic is whether you are running on a dual-mode stack or not.  
The way i undestand it is, if you are e.g. writing a server that is  
supposed to work for both v4 and v6, for a dual-mode stack you only  
have to bind to '::' (I am generalizing wildly), and it will actually  
accept both v4 and v6 connections, whereas for a non-dual-mode stack,  
you would actually have to create two listening sockets, one on '::'  
and one on '0.0.0.0'...


Kind Regards,

/johan

-- 
Johan Liseborn

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2363 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20051104/bd6d9556/attachment.p7s>

Posted on the users mailing list.