Page 1 of 1
GetLocalIP() with #NETWORKSERVER
Posted: Wed Mar 25, 2020 3:22 am
by PEB
Try this code:
Code: Select all
CreateServer(1)
DebugPrint(GetLocalIP(1, #NETWORKSERVER))
OpenConnection(1, "www.google.com", 80)
DebugPrint(GetLocalIP(1, #NETWORKCONNECTION))
Using #NETWORKSERVER always returns "0.0.0.0" whatever machine runs it; but #NETWORKCONNECTION returns the actual local IP address for the machine.
Re: GetLocalIP() with #NETWORKSERVER
Posted: Sat Mar 28, 2020 12:28 pm
by airsoftsoftwair
Ok, this looks like a bug. Will be fixed.
Re: GetLocalIP() with #NETWORKSERVER
Posted: Mon Sep 07, 2020 4:03 pm
by airsoftsoftwair
Alright, so this isn't a bug. If you specify * as the ip$ (which is the default),
CreateServer() will bind the server to all interfaces, i.e. typically the network interface (192.168.x.x) but also the loopback interface (127.0.0.1). Because of this, it's impossible for
GetLocalIP() to return a single IP address because the server is bound to at least two interfaces. Thus, you just get the wildcard 0.0.0.0 as the return value. If you don't want that, bind the server to a single IP address by passing it in the ip$ argument to
CreateServer().
Re: GetLocalIP() with #NETWORKSERVER
Posted: Mon Sep 07, 2020 9:17 pm
by PEB
Interesting. So is there a way to get Hollywood to return the LocalIP address (assuming it's not known) without first making contact with the outside world (like using OpenConnection(1, "
www.google.com", 80) does)?
Re: GetLocalIP() with #NETWORKSERVER
Posted: Mon Sep 07, 2020 10:20 pm
by airsoftsoftwair
PEB wrote: ↑Mon Sep 07, 2020 9:17 pm
Interesting. So is there a way to get Hollywood to return the LocalIP address (assuming it's not known) without first making contact with the outside world (like using OpenConnection(1, "
www.google.com", 80) does)?
It's possible but can be a little inconvenient. See here for an approach:
viewtopic.php?f=4&t=2421&p=13090#p13085
A better way to do this is in the works, though.
Re: GetLocalIP() with #NETWORKSERVER
Posted: Tue Sep 08, 2020 4:53 am
by PEB
Sounds good.
Thanks for all the improvements you keep making.
(I'm eager to show my support by purchasing the newest version when it's ready for release.)
Re: GetLocalIP() with #NETWORKSERVER
Posted: Wed Sep 09, 2020 6:37 pm
by airsoftsoftwair
Done now:
Code: Select all
- New: Added GetLocalInterfaces() to the network library; this will return a list of all interfaces that
are currently available; it will return a table that contains "Name", "Address", and "Protocol" for each
item; this allows you to conveniently determine a system's local IP address