How to check if there is internet connection?

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How to check if there is internet connection?

Post by FourthWorld » Mon Feb 07, 2022 6:08 pm

Is the goal to check that the server is up, or to obtain the user's public IP address?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to check if there is internet connection?

Post by jacque » Mon Feb 07, 2022 6:15 pm

I don't know much about it either but if they're using a proxy then I think that's what you'll get back. But that's okay since that's the public facing machine.

Check the result to see if they're connected, or put the request into a try block to catch any errors. IOS has a function to check for connectivity but Android doesn't, so you may as well use the same method for both.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: How to check if there is internet connection?

Post by trevix » Mon Feb 07, 2022 6:50 pm

@FourthWorld
Both. To check if the mobile device has an internet connection and, if that's the case, obtain its public address.

@ jacque
put the request into a try block to catch any errors
I don't think it will work. If there is no answer, there gonna be no answer for a while.Then a timeout should be used. Don't you think?
IOS has a function to check for connectivity
Really?
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7215
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: How to check if there is internet connection?

Post by jacque » Mon Feb 07, 2022 7:29 pm

If there's no connection then you're right. If there are actual errors you may want to catch those too.

IOS has some "reachability" messages and functions. The reachabilityChanged message gives some info about the connection. It's not exactly a check for internet, but close.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How to check if there is internet connection?

Post by FourthWorld » Mon Feb 07, 2022 8:43 pm

What will be done with the user's IP address?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: How to check if there is internet connection?

Post by trevix » Tue Feb 08, 2022 9:58 am

We have a hosted DB for analytics: the IP is used for geographical location of our users
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How to check if there is internet connection?

Post by FourthWorld » Tue Feb 08, 2022 10:22 am

trevix wrote:
Tue Feb 08, 2022 9:58 am
We have a hosted DB for analytics: the IP is used for geographical location of our users
You don't use the Apache logs for that? They're a treasure trove.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

trevix
Posts: 958
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: How to check if there is internet connection?

Post by trevix » Tue Feb 08, 2022 10:52 am

Didn't even know it existed (uh!). But what a level of complexity!
Anyway, we are a very small startup, our is not a web app, and we collect data of user activities all across the standalone, sending them at launch to a hosted DB.
We started with a Filemaker server running on my living room (!).
The plan is to move data collection to a MySQL DB so as to have a more popular tool to analyze the data.
Programming absorbs most of our time and we have to scale very gradually to the analytic part of our activities.
Any suggestion is welcomed, anyway
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

Post Reply

Return to “Internet”