Child pages
  • IPv6 programming
Skip to end of metadata
Go to start of metadata

C / C++

For name resolution, use the getaddrinfo(3) and getnameinfo(3) functions. Ulrich Drepper has an excellent tutorial on them.

getaddrinfo() is standardized in the Single Unix Specification Version 3, in POSIX 1003.1g-2000 and in RFC 2553. It has been the recommended name resolution function for Unix since 1999. It supersedes gethostbyname(), gethostbyname2(), gethostbyaddr(), getipnodebyaddr(), and getipnodebyname().

Problems with older name resolution functions

gethostbyname() is not IPv6-capable.

gethostbyname2() was an early "quick hack" that tried to add IPv6 support into gethostbyname(). It is cumbersome to use, however.

The getipnodebyname() and getipnodebyaddr() functions were specified by RFC 2553 (Basic Socket Interface Extensions for IPv6). They were never included in the Single Unix Specification. In 2003, RFC 2553 was obsoleted by RFC 3493, which deprecated them in favor of getaddrinfo(). Further, they aren't supported on NetBSD and OpenBSD.

Platform support

getaddrinfo() is supported on:

OS

Year support added

Notes

RedHat Linux 6.1

1999

 

Solaris 8

2000

 

FeeBSD 4.0

2000


NetBSD 1.5

2000


OpenBSD 2.0

2001


AIX 5.2

2002

allegedly, AIX 4.3 supported this, but I've had issues with it on 4.3 and 5.1.

IRX 6.5.19

2003

I've not tested this, since I lack access to an IRIX machine.

Mac OS X 10.3

2003

Possibly supported on 10.2 as well, but I lack access to that version

HP-UX 11i

2000

Untested, due to lack of access.

OpenVMS 7.3-1

2003

Untested, due to lack of access

getaddrinfo() is not supported on cygwin.

getaddrinfo() has been supported in glibc since version 2.2.

AI_ADDRCONFIG flag

On many platforms, getaddrinfo() can take the AI_ADDRCONFIG flag. This instucts getaddrinfo() to only obtain addresses that are usable. For instance, if a client does not have an IPv6 address, getaddrinfo() won't query for AAAA records, since the client couldn't use them. Unfortunately, AI_ADDRCONFIG isn't supported on all platforms.

AI_ADDRCONFIG supported on:

  • Linux
  • Solaris
  • Mac OS X 10.4 +
  • AIX 5.2

AI_ADDRCONFIG is broken on:

  • FreeBSD
  • Mac OS X 10.3

On these platforms, programs with AI_ADDRCONFIG will compile, but both AAAA and A records will be requested.

AI_ADDRCONFIG is not supported on:

  • NetBSD
  • OpenBSD
  • AIX 4.3

On these platforms, programs with AI_ADDRCONFIG will not compile.

Networking libraries

GNet 2 supports IPv6. GNet 1 does not.

Apple's CFNetwork library is IPv6-capable.

OpenSSL's BIO API is not IPv6-capable, but support is under development.

Qt 3.3 and higher supports IPv6.

NSPR has supported IPv6 since version 3.5, released in 1999. See chapter 11 of the NSPR reference manual for more.

APR has supported IPv6 since before version 1.0.

ACE (the Adaptive Communication Environment), has supported IPv6 since version 5.3, released in 2003.

RealBasic

RealBasic does not support IPv6, and its developers have no plans to add support.

Python

See IPv6 and Python.

Perl

Perl programs are difficult to IPv6-enable because the Perl Socket module does not include IPv6 support. Instead, you must use the Socket6 or the IO::Socket::INET6 module to get IPv6. Not all platforms include Socket6 by default.

To check if your platform's Perl interpreter support IPv6, run the following:

$ perl -MSocket6 -e1
$ perl -MIO::Socket::INET6 -e1

If the above commands complete without error, you have IPv6 support.

Perl IPv6 support by platform

OS

Socket6

IO::Socket::INET6

Mac OS X 10.4

no

no

Mac OS X 10.5

yes

yes

Solaris 10

no

no

Solaris Express (b77)

no

no

Blastwave Perl (5.8.8,REV=2007.10.05)

no

no

CentOS 3.x and 4.x

no

no

CentOS 5

yes

yes

Fedora Core 6

yes

yes

Ubuntu 6.04, 6.10 and 7.04

no

no

Ubuntu 7.10

yes

yes

ActivePerl 5.8.8 (build 882)

no

no

ActivePerl 5.10.0 (build 1002)

no

no

Cygwin Perl 5.8.8

no

no

StrawberyPerl 5.10.0

no

no

Microsoft SDK for Unix-based Apps

no

no

FreeBSD 6.2*

no

no

AIX 5.3

no

no

* On FreeBSD, you can install Socket6 and IO::Socket::INET6 from /usr/ports/net/p5-Socket6 and /usr/ports/net/p5-IO-INET6, respectively.

IPv6-capable Perl Modules

non-IPv6-capable Perl modules

Java

Java has been IPv6-capable since version 1.4. Most, but not all, Java apps are IPv6-clean. By default, Sun's JVM will run in dual-stack mode, supporting both IPv6 and IPv4 addresses. You can force the JVM to only support IPv4 by setting:

-Djava.net.preferIPv4Stack=true

Even in dual-stack mode, the JVM preferes to use A records when performing name resolution. You can set it to prefer AAAA records by setting:

-Djava.net.preferIPv6Addresses=true

See Sun's JDK documentation for specifics.

Sun also has documentation on programming for IPv6 in Java.

JBoss has some docs on bugs in IPv6 on Java.

IPv6-capable Java libraries

  • Apache Commons-Net's Whois client

Non-IPv6-capable Java libraries

  • Apache Commons-Net's FTP client (does not implement IPv6 FTP extensions), as of 2.0
  • Apache Commons-Net's SubnetUtils, as of 2.0

Windows

Microsoft has several useful documents on IPv6 programming:

To develop Winsock IPv6 programs, you will need:

  • Microsoft Platform Software Development Kit (SDK), January 2000 or later (available from the MSDN Web site).
  • Microsoft Visual C++ version 6.0 or later.
  • A computer running Windows Vista, Windows Server 2008, Windows Server 2003, or Windows XP with SP1 or later, with IPv6 installed.

Per-OS support:

OS

WinSock

WinINet

IPHelper

RPC

DCOM

WinHTTP 2

HTTP.sys

XP SP2

Yes

Yes

No

 

No

Yes

 

Vista

Yes

Yes

 

 

 

Yes

Yes

Server 2003 SP2

Yes

Yes 1

Yes

Yes

Yes

Yes

Yes

Server 2008

Yes

Yes

 

 

 

Yes

Yes

1. WinINet does not support IPv6 literal addresses in XP and 2003. See this document for more.

2. WinHTTP 5.1 and higher support IPv6.

Source code analyzers

Several companies have released utilities which analyze source code for non-IPv6-clean code. These tools won't catch everything, but they are a good place to start.

Microsoft has the checkv4 utility.

The EUChinaGrid project has the IPv6 code checker which works with C, Java, Perl and Python.

The EGEE (Enabling Grids for E-science) program has developed IPv6-care, which works with C, Java, Perl and Python.

Sun has the IPv6 Socket Scrubber (free registration required to download).

  • No labels