IPv6 Sockets for TclRafael Martínez TorresDonal K. FellowsReinhard Max$Revision: 1.16 $
This TIP is about allowing Tcl to use IPv6 sockets in virtually the same way that you would use the current (IPv4) sockets.
IPv6 is the next generation of the IP protocol that underlies Internet sockets. IPv6 advantages include a wider address space (128 bits instead current 32 bits), improved mobility, mandatory security at IP layer (IPsec...), etc. Tcl should allow the programmers try both protocols at their networking programs without too much effort (dependant on underlying operating system support, of course), just accepting the literal address (192.0.2.42, 2001:DB8::baad:f00d) or the DNS names (www.example.com).
The interpreter should understand:
c29ja2V0IDE5Mi4wLjIuNDIgaHR0cA==c29ja2V0IDIwMDE6REI4OjpiYWFkOmYwMGQgZWNobw==c29ja2V0IC1zZXJ2ZXIgYWNjZXB0IDk5OTk=c29ja2V0IGlwdjYuZXhhbXBsZS5jb20gODA4MA==
Where a hostname resolves to multiple addresses in multiple families, the addresses are tried one by one as returned by the the resolver library until a connection can be established. The order depends on the resolver library and its configuration; it is deliberately not touched by Tcl, so that local preferences are automatically respected by Tcl programs.
For sockets that actually use IPv6 the output of fconfigure needs to be changed to reflect the fact:
Client sockets:
JSBmY29uZmlndXJlIHNvY2s1IC1wZWVybmFtZQ==MjAwMTpEQjg6OmJhYWQ6ZjAwZCBpcHY2LmV4YW1wbGUuY29tIDc=JSBmY29uZmlndXJlIHNvY2s1IC1zb2NrbmFtZQ==MjAwMTpEQjg6OmRlYWQ6YmVlZiAyMDAxOkRCODo6ZGVhZDpiZWVmIDQ5MTk4
Server sockets:
JSBzb2NrZXQgLXNlcnZlciBhY2NlcHQgMA==c29jazM=JSBmY29uZmlndXJlIHNvY2szIC1zb2NrbmFtZQ==MC4wLjAuMCAwLjAuMC4wIDQ5MTk4IDo6IDo6IDQ5MTk4
The -sockname and -peername options are the affected ones; for client sockets they can indicate addresses in the IPv6 or IPv4 namespaces, and for server sockets the -sockname option will list all the addresses bound (2 in the above example), three elements each. To maximize backward compatibility, the IPv4 address (if bound) will always be listed first. (Client sockets will always only list a single address as they will always be connected by a definite protocol.)
A development branch has been opened up; see [] for details.
An older patch is available for UNIX platforms [].
This document has been placed in the public domain.