14.12.2017, 16:26
Hi,
In some of my scripts it would be useful to know the IP address of the Logic Machine on which they run.
Now I use something I found somewhere:
I don't know how it works, but it works (and does not require a connection to the IP address in the script. As a matter of fact that IP address is irrelevant).
Is there a more elegant solution?
Thanks
In some of my scripts it would be useful to know the IP address of the Logic Machine on which they run.
Now I use something I found somewhere:
Code:
require('socket')
local s = socket.udp()
s:setpeername("192.168.1.1",80)
local ip, _ = s:getsockname()
log(ip)
I don't know how it works, but it works (and does not require a connection to the IP address in the script. As a matter of fact that IP address is irrelevant).
Is there a more elegant solution?
Thanks