[racket] How to use tcp-listen with IPv6 on Linux?

From: Ken Shirriff (ken.shirriff at gmail.com)
Date: Sat Feb 26 15:07:23 EST 2011

I'm trying to get Racket to listen on an IPv6 port, but I can only get
it to work with IPv4.

> (tcp-listen 8080 5 #t)
I would expect this to listen on both IPv4 and IPv6 but lsof shows
it's only listening on IPv4.

Specifying an explicit IPv6 address doesn't work at all:

> (tcp-listen 8080 5 #t "::")
tcp-listen: host not found: :: (Unknown host; errno=1)

> (tcp-listen 8080 5 #t "2001:1938:81:1f8::2")
tcp-listen: host not found: 2001:1938:81:1f8::2 (Unknown host; errno=1)

Specifying a name that resolves to the IPv6 address of my local host
doesn't work:

> (tcp-listen 8080 5 #t "ipv6.nlanguages.com")
tcp-listen: host not found: ipv6.nlanguages.com (No address associated
with name; errno=4)

My machine is running IPv6, ifconfig shows that IPv6 address, the name
resolves, and I can listen on an IPv6 port with Python, so my IPv6
setup seems to be okay.

I've tried MzScheme v4.1.2 and Racket v5.1 on two different Linux
machines without success.  (Strangely, tcp-listen works fine with IPv6
on Windows.)

Is there some mzscheme flag necessary to use IPv6?  Or do I need some
obscure Linux name resolution configuration change?  I've looked at
the mzscheme documentation and even the racket/src/network.c source
code, and I can't figure this out.

Thanks for your help,

Posted on the users mailing list.