Method of detecting a valid internet connection

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

Method of detecting a valid internet connection

Post by reelstuff » Wed Mar 30, 2011 2:07 pm

I am looking to see if there is a method of determining a valid connection to the internet. (desktop app)

Since, I have content I want to display inside an app, if there is a connection, however if there is no connection I need to be able to show default content in place of live content.

This is so that there would be no content issues or perhaps say a 404 or other error code.

I suppose that you could ping a URL and determine if there is a valid status code, HTTP Status Codes 200 would indicate a valid internet connection.

someone else posted about detecting an iOS connection to wifi, I wonder if you could do the same thing in iOS?

Any thought, suggestions, ect, thanks in advance.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Method of detecting a valid internet connection

Post by Dixie » Wed Mar 30, 2011 6:38 pm

Hi...

This function was posted by Mark Schonewille some time ago..

Code: Select all

function connectionAlive
  put "255.255.255.255:44444" into mySock
  open datagram socket to mySock
  put hostAddress(mySock) into myIP1
  close socket mySock
  if myIP1 is "127.0.0.1" then
    return false
  else
    return true
  end if
end connectionAlive
Hope it helps.. it helped me !

be well

Dixie

Post Reply