lua-users home
lua-l archive

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


Hi William,

> The canonical way to do this is to create and bind a socket to a known
> public address, such as 8.8.8.8 (Google's public DNS service) and then call
> getsockname to get the local IP. You don't even need to connect the socket.
> The socket bind will force the kernel to resolve the proper local address
> according to its routing table.

Thank you for the suggestion. I did get it working, but not without
connecting to the socket:

socket.connect('8.8.8.8', 53):getsockname()

I tried something similar using socket.bind, but it only binds to
local addresses (to create a listening socket). Am I missing something
in the luasocket API?

Paul.