lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hope this is the right place :) (can't find an email address for Diego
Nehab, so if someone could forward this to him, that'd be nice) - I'm
just starting to get into Lua programming by way of MattJ's Prosody IM
server (, which I installed to replace ejabberd last

One of the regressions against ejabberd that I noticed was that prosody
doesn't have IPv6 support - because LuaSocket doesn't have it either.
Given that it's 2009, I find that rather shocking so I've set out to
patch LuaSocket to include IPv6 support.

I'm developing against the 2.0.3rc1 release and I'm currently at a point
where I can get the test suite to bind to an IPv6 address - remainder of
the functionality to follow, here's some fun:

$ lsof |grep TCP |grep lua
lua       16006     lupine    3u     IPv6              94132
TCP localhost:44248 (LISTEN)

$ netstat -lnt |grep 44248
tcp6       0      0 ::1:44248               :::*

In terms of Lua API implementation, I'm currently going for the most
lightweight and backward-compatible approach I can think of, which is to
add an optional af_family ("AF_INET" or "AF_INET6") parameter to various
entry points where previously LuaSocket just presumed AF_INET
(socket:tcp, socket:udp, socket.bind, socket.connect being the main
ones, of course - and the smtp, ftp, etc classes too, perhaps, to
leverage the new functionality). 

One other change that I'm about halfway through is migrating everything
to use getaddrinfo and friends; this change is necessary to get halfway
sensible dual-stack implementation, and although it's likely to change
the behaviour of LuaSocket's DNS section a little bit (changing the
record passed back in some circumstances, perhaps), it's a Good Change
in and of itself IMO.  It also has the incidental advantage of making
(that part of) LuaSocket thread-safe, by all accounts - not sure how
useful that is since I'm still a rank Lua coder by any standards ;).

Code is "coming soon" - I thought I'd just give a shout out after my
initial success, to get opinions on how this should be done - preference
given to Diego's comments/preferences, of course! :). I understand he's
spoken with Matt about it a bit, so I'd like to coordinate on this as
much as possible; I've no intentions of forking my own ipv6 luasocket
for any longer than absolutely necessary ;)