
Function CheckMyWebsiteAvailable
Put "Status:NoInternet" into ccMyWebsiteStatus
Set the socketTimeoutInterval to 1500
Put true into ccTryTransmit
Put 1 into ccCount
// Try twice to make contact
Repeat until not ccTryTransmit
post "" to URL "http://MyWebsite.com/test-status.php"
put it into ccMyWebsiteResponse
If ccMyWebsiteResponse = "Status:Received" then
Put "Status:OKMyWebsite" into ccMyWebsiteStatus
Else
put URL "http://www.google.com" into ccConnCheck
if ccConnCheck is empty then
Put "Status:NoInternet" into ccMyWebsiteStatus
Else
Put "Status:NoMyWebsite" into ccMyWebsiteStatus
End if
End if
Put ccCount+1 into ccCount
If ((ccMyWebsiteStatus = "Status:OKMyWebsite") or (ccCount = 3)) then put false into ccTryTransmit
end Repeat
Return ccMyWebsiteStatus
end CheckMyWebsiteAvailable
Then I either display an error message, or carrying on with whatever action required communication to my website, depending on the value returned by CheckMyWebsiteAvailable().
If I have GOOD internet connectivity - the above works fine.
If I have ZERO internet connectivity (test device in flight mode) - the above works fine. My app comes back with my elegant error message after a couple of seconds.
But if I have V.POOR internet connectivity - the above function doesn't work. The user pushes a button that should trigger some communication with my website, then nothing happens. I've sat there and watched over a minute go past - no error message, no actions. FYI - V.POOR internet connectivity = I downloaded a map of my mobile service providers network coverage, then drove out and parked up in a spot where the test device alternated between 0 bar and 1 bar of 3G coverage. Then I spent an hour testing my app. It must have looked very odd

What I want to happen is have my function return a "Status:NoInternet" if it can't get a response from myWebsite or Google in under 10 seconds.
Does anyone else have some code for testing for internet connectivity, that correctly handles situations of present but very poor connectivity? Re-reading the forums has got me wondering whether I need an On SocketTimeout handler. I know nothing about sockets, but is this what I'm missing?
Thanks in advance