[plt-scheme] IPv6?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Nov 4 07:59:17 EST 2005

At Fri, 4 Nov 2005 10:29:36 +0100, Johan Liseborn wrote:
> Are you using 'getaddrinfo' to resolve addresses?

Yes.

> OK, so does that mean that the following will be true:
> 
> (tcp-listen 5060)
> 
> Bind a socket to 127.0.0.1 on port 5060 (as before).

The socket will be bound to all IPv4 interfaces. So it will bind at
127.0.0.1, and also at 155.98.63.210 if the machine is
www.plt-scheme.org.

> (tcp-listen 5060 5 "localhost")
> 
> Bind a socket to whatever address "localhost" is mapped to  
> (presumably in /etc/hosts), which may be either an IPv4 address (e.g.  
> 127.0.0.1) or and IPv6 address (e.g. ::1).

Yes -- and yes to all the other examples like this.

> >  * Depending on your system's capabilities, you might supply "::" as
> >    the local hostname for `tcp-listen' to get a listener that accepts
> >    both IPv4 and IPv6 connections. This works under Mac OS X and
> >    Linux, for example, but under Windows it creates an IPv6-only
> >    listener.
> 
> Hmm, I am not 100% sure, but isn't '::' (or '0:0:0:0:0:0:0:0')  
> comparable to '0.0.0.0' for IPv4 (i.e. the unspecified address, which  
> for binding usually means "bind to all addresses")? I believe ':: 
> 1' (or '0:0:0:0:0:0:0:1') is comparable to '127.0.0.1' (i.e. the  
> "loopback" address).

That's all correct.

> So, how does the current implementation work:
> 
> (tcp-listen 5060 5 "::")
> 
> Binds only to the loopback address
> 
> or
> 
> Binds to *all* addresses

All IPv6 addresses --- and for most systems (not Windows), all IPv4
addresses, too.

> I believe the Right Thing would be for (tcp-listen 5060 5 "::1") to  
> bind to the loopback address, and for (tcp-listen 5060 5 "::") to  
> bind to all addresses.

Yes, that's how it works.

> >    Arguments to `udp-open-socket' merely determine the socket's
> >    protocol family; `udp-open-socket' doesn't bind the socket. If the
> >    socket is going to be used to communicate with a specific host,  
> > then
> >    supplying the host to `udp-open-socket' is a good way to ensure  
> > that
> >    the socket's protocol family is consistent with the target host.
> >    Similarly, if the socket is going to be bound to a particular host
> >    and port, supplying those values to `udp-open-socket' ensures that
> >    the binding will work.
> 
> OK, so again, are you using 'getaddrinfo' to resolve, and the type of  
> socket I get is whatever 'getaddrinfo' gives you?

Yes.

Thanks,
Matthew



Posted on the users mailing list.