get the networkInterfaces: distinguish more IP
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
get the networkInterfaces: distinguish more IP
Hello.
I use the property "networkInterfaces" in order to obtain the IP number of the device where I am running my stack.
If my device is ethernet wired and it is set so has to run an hotspot (to share with wifi the internet connection), the networinterface as it should, returns 2 IP numbers, beside the 127.xxx.
Is there a way to distinguish in LC which IP is the ethernet IP and which is the hotspot IP?
Thanks for the help
Trevix
I use the property "networkInterfaces" in order to obtain the IP number of the device where I am running my stack.
If my device is ethernet wired and it is set so has to run an hotspot (to share with wifi the internet connection), the networinterface as it should, returns 2 IP numbers, beside the 127.xxx.
Is there a way to distinguish in LC which IP is the ethernet IP and which is the hotspot IP?
Thanks for the help
Trevix
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: get the networkInterfaces: distinguish more IP
On which platform?
You might try shelling out to ifconfig to see which address is attached to the wlan interface.
Unless you're using Windows in which case it's ipconfig.
You might try shelling out to ifconfig to see which address is attached to the wlan interface.
Unless you're using Windows in which case it's ipconfig.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: get the networkInterfaces: distinguish more IP
Sorry, on Android.
Server and client are both on a local network.
I have a TvBox that act as a server, connected with ethernet and also sharing internet with the hotspot enabled.
The client (mobile) is always on wifi, and must be given the Ip of the server hotspot, in order to connect
For what I understand, the order of the list returned by "the networinterface" is:
- ethernet IP
- hotspot IP
- local 127.0.0.1
But is this a rule?
Can I count on it?
Or is a router decision?
Server and client are both on a local network.
I have a TvBox that act as a server, connected with ethernet and also sharing internet with the hotspot enabled.
The client (mobile) is always on wifi, and must be given the Ip of the server hotspot, in order to connect
For what I understand, the order of the list returned by "the networinterface" is:
- ethernet IP
- hotspot IP
- local 127.0.0.1
But is this a rule?
Can I count on it?
Or is a router decision?
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: get the networkInterfaces: distinguish more IP
The client and the server are both on Android?
The order of the interfaces isn't determined by the LiveCode engine - it just returns the result of querying the operating system.
But I'm confused now. I'm probably misunderstanding this, but it sounds like the client connects to the server and then you want the server to send the client a different ip address to connect with instead?
The order of the interfaces isn't determined by the LiveCode engine - it just returns the result of querying the operating system.
But I'm confused now. I'm probably misunderstanding this, but it sounds like the client connects to the server and then you want the server to send the client a different ip address to connect with instead?
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: get the networkInterfaces: distinguish more IP
I am very sorry: this network stuff is very confusing to me and not easy to explain.
The client can be Android or iOS, according to the user cell phone.
The server hardware, which we sell, is always Android and, upon first launch, must be configured with one this two user's choice:
- manually paired to WiFi (if exists) on the OS settings
- connected to ethernet and enabling its hotspot on the OS settings
When the LC app of the server is first launched, it shows a screen with its local IP number, so that the client, after pairing its phone to the same wifi or to the hotspot wifi, can socket connect to it.
What I am trying to solve is to display on the server, when in hotspot mode, the hotspot IP (not the ethernet IP).
Networinterfaces was returned in this order:
- 127.0.0.1
- IP of wifi
- IP of ethernet
So, apparently, it returns a list according to whatever comes first.
Then I disconnected WiFi, leaving ethernet:
- 127.0.0.1
- ethernet IP ---correct
and enabling again WiFi:
- 127.0.0.1
- IP of wifi
- IP of ethernet
This last order shows that "whatever comes first" is not true.
Any idea?
The client can be Android or iOS, according to the user cell phone.
The server hardware, which we sell, is always Android and, upon first launch, must be configured with one this two user's choice:
- manually paired to WiFi (if exists) on the OS settings
- connected to ethernet and enabling its hotspot on the OS settings
When the LC app of the server is first launched, it shows a screen with its local IP number, so that the client, after pairing its phone to the same wifi or to the hotspot wifi, can socket connect to it.
What I am trying to solve is to display on the server, when in hotspot mode, the hotspot IP (not the ethernet IP).
As a confirmation of your answer, I connected, as a test proof, the mac to wifi and, only after, connected the ethernet cable.The order of the interfaces isn't determined by the LiveCode engine - it just returns the result of querying the operating system.
Networinterfaces was returned in this order:
- 127.0.0.1
- IP of wifi
- IP of ethernet
So, apparently, it returns a list according to whatever comes first.
Then I disconnected WiFi, leaving ethernet:
- 127.0.0.1
- ethernet IP ---correct
and enabling again WiFi:
- 127.0.0.1
- IP of wifi
- IP of ethernet
This last order shows that "whatever comes first" is not true.
Any idea?
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>
Re: get the networkInterfaces: distinguish more IP
Another reason why I need to distinguish the ethernet IP from the hotspot IP, is that at each hardware restart of the server, the hotspot IP changes.
A different type of user, will connect to the registered server using the QRcode displayed by it.
Since the only way in LC server to see if the user has changed the wifi, in case in the server it is using the wifi, not the hotspot, and that he has to re-enter the SSDI and password to be shown on the QRcode for this type of users, is to check if the IP has changed.
A different type of user, will connect to the registered server using the QRcode displayed by it.
Since the only way in LC server to see if the user has changed the wifi, in case in the server it is using the wifi, not the hotspot, and that he has to re-enter the SSDI and password to be shown on the QRcode for this type of users, is to check if the IP has changed.
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>
-
- VIP Livecode Opensource Backer
- Posts: 7257
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: get the networkInterfaces: distinguish more IP
Can you assign a static ethernet IP to the server? Then the wifi IP will be the other one. Or maybe you can assign static IPs to both ethernet and wifi?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: get the networkInterfaces: distinguish more IP
Also, I'll assume the wifi address is static, or at least the subnet doesn't change. If that's the case, can you just eliminate it from the list?
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev