lua-users home
lua-l archive

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


How about I make the automatic name resolution in LuaSocket to follow the
principled approach of trying addresses in the order returned by getaddrinfo?
Users could invoke the name resolution function themselves, and filter
out the resolved addresses based on their own family requirements?

In other words, socket.connect("", 80) would try whatever
the resolve returns: perhaps IPv6 first then if that fails IPv4, or perhaps the
only address returned is IPv4 so that's what connect tries. On the other hand,
socket.connect("", 80) would obviously try to connect only through
IPv4 and fail through to the user if that doesn't work, whereas
socket.connect("2001:db8::1", 80) would try only IPv6. Since the user can
perform his/her own name resolution, this would be the method to control
specific behavior without weighting the API down with options.

Wouldn't that be both simple and general enough to satisfy everyone?

Maybe the connect() call could accept a table of IP addresses to try
in sequence, so that socket.connect("", 80) is equivalent to
socket.connect(socket.toip(""), 80), assuming socket.toip()
simply returns the list of resolved addresses in the order provided by