|Title:||IPv6 Sockets for Tcl|
|Version:||$Revision: 1.16 $|
Rafael Martínez Torres <rafael dot martinez at novagnet dot com>|
Donal K. Fellows <donal dot k dot fellows at manchester dot ac dot uk>
Reinhard Max <max at tclers dot tk>
|Created:||Thursday, 23 October 2003|
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:
socket 192.0.2.42 http socket 2001:DB8::baad:f00d echo socket -server accept 9999 socket ipv6.example.com 8080
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:
% fconfigure sock5 -peername 2001:DB8::baad:f00d ipv6.example.com 7 % fconfigure sock5 -sockname 2001:DB8::dead:beef 2001:DB8::dead:beef 49198
% socket -server accept 0 sock3 % fconfigure sock3 -sockname 0.0.0.0 0.0.0.0 49198 :: :: 49198
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.
[Index] [History] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]TIP AutoGenerator - written by Donal K. Fellows