<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://tcl.activestate.com/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Thu Feb 09 12:47:05 GMT 2012 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='162'>
<header><title>IPv6 Sockets for Tcl</title><author address="mailto:rafael.martinez@novagnet.com">Rafael Martínez Torres</author><author address="mailto:donal.k.fellows@manchester.ac.uk">Donal K. Fellows</author><author address="mailto:max@tclers.tk">Reinhard Max</author><status type='project' state='final' tclversion="8.6" vote='after'>$Revision: 1.16 $</status><history></history><created day='23' month='oct' year='2003' /></header>
<abstract>This TIP is about allowing Tcl to use IPv6 sockets in virtually the same way that you would use the current (IPv4) sockets.</abstract>
<body><section title="Rationale">
<para>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).</para>
</section>
<section title="Proposed Change">
<para>The interpreter should understand:</para>
<verbatim><vline encoding='base64'>c29ja2V0IDE5Mi4wLjIuNDIgaHR0cA==</vline><vline encoding='base64'>c29ja2V0IDIwMDE6REI4OjpiYWFkOmYwMGQgZWNobw==</vline><vline encoding='base64'>c29ja2V0IC1zZXJ2ZXIgYWNjZXB0IDk5OTk=</vline><vline encoding='base64'>c29ja2V0IGlwdjYuZXhhbXBsZS5jb20gODA4MA==</vline></verbatim>
<para>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.</para>
<para>For sockets that actually use IPv6 the output of <emph style="bold">fconfigure</emph> needs to be changed to reflect the fact:</para>
<para>Client sockets:</para>
<verbatim><vline encoding='base64'>JSBmY29uZmlndXJlIHNvY2s1IC1wZWVybmFtZQ==</vline><vline encoding='base64'>MjAwMTpEQjg6OmJhYWQ6ZjAwZCBpcHY2LmV4YW1wbGUuY29tIDc=</vline><vline encoding='base64'>JSBmY29uZmlndXJlIHNvY2s1IC1zb2NrbmFtZQ==</vline><vline encoding='base64'>MjAwMTpEQjg6OmRlYWQ6YmVlZiAyMDAxOkRCODo6ZGVhZDpiZWVmIDQ5MTk4</vline></verbatim>
<para>Server sockets:</para>
<verbatim><vline encoding='base64'>JSBzb2NrZXQgLXNlcnZlciBhY2NlcHQgMA==</vline><vline encoding='base64'>c29jazM=</vline><vline encoding='base64'>JSBmY29uZmlndXJlIHNvY2szIC1zb2NrbmFtZQ==</vline><vline encoding='base64'>MC4wLjAuMCAwLjAuMC4wIDQ5MTk4IDo6IDo6IDQ5MTk4</vline></verbatim>
<para>The <emph style="bold">-sockname</emph> and <emph style="bold">-peername</emph> options are the affected ones; for client sockets they can indicate addresses in the IPv6 or IPv4 namespaces, and for server sockets the <emph style="bold">-sockname</emph> 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.)</para>
</section>
<section title="Reference Implementation">
<para>A development branch has been opened up; see [<url ref="http://wiki.tcl.tk/25947"/>] for details.</para>
<para>An older patch is available for UNIX platforms [<url ref="http://www.ngn.euro6ix.org/IPv6/tcl"/>].</para>
</section>
<section title="Copyright">
<para>This document has been placed in the public domain.</para>
</section>
</body></TIP>

