[plt-scheme] IPv6?
On Nov 3, 2005, at 22:41, Matthew Flatt wrote:
> At Sat, 23 Jul 2005 10:35:20 +0200, Johan Liseborn wrote:
>> Are there any plans on adding IPv6 support to PLT Scheme?
>
> MzScheme in the SVN respository trunk supports IPv6.
Great news!
I haven't checked the code out and tried it yet, but I'll try to give
some initial comments anyway. Note though, that I am by no means an
expert on IPv6 (one of the reasons I wanted IPv6 support in MzScheme
was so that I could start playing with it).
Maybe it would be a good idea to have some discussion on this thread
before you take my word for it and start changing things... :-)
Are you using 'getaddrinfo' to resolve addresses?
> * By default, `tcp-listen' and `udp-open-socket' create sockets that
> work with IPv4, only. For `tcp-connect', etc., the hostname
> determines the protocol family.
>
> * 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.
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).
(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).
(tcp-listen 5060 5 "foobar.example.org")
Bind a socket to whatever address "foobar.example.org" is mapped to,
wither IPv4 or IPv6.
(tcp-listen 5060 5 "192.0.2.10")
Bind to the actual IPv4 address given.
(tcp-listen 5060 5 "1080:0:0:0:8:800:200C:417A")
Bind to the actual IPv6 address given.
> * 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).
So, how does the current implementation work:
(tcp-listen 5060 5 "::")
Binds only to the loopback address
or
Binds to *all* addresses
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.
If I understand things correctly, whether something like '::' will
give you a socket that accepts both v4 and v6, or v6 only depends on
the type of stack, i.e. whether it is a "dual-mode" stack or not, and
thus is not possible to manipulate through the socket APIs.
> * The `udp-open-socket' function now accepts optional hostname and
> port arguments. If they're supplied, then the new socket's protocol
> family is the one implied by the address and port. For example,
> `(udp-open-socket "::")' creates an IPv6 socket if the system
> supports it. On some systems (e.g., Linux), the resulting IPv6
> socket can also send and receive IPv4; on some systems (e.g.,
> Mac OS
> X), it can only receive IPv4; on some systems (e.g., Windows), it
> doesn't support IPv4 at all.
>
> 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?
/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/6d592a2f/attachment.p7s>