Check connection and timeout

Bob Sneidar bobsneidar at
Fri Jul 14 12:21:34 EDT 2023

Hi Ludovic. 

I use a simple method of sockets to determine if I have a connection to a host. I close the socket first: 


Then I open the socket:

Open socket to
Put the result into tError

If terror begins with “ERROR: “ then
   — your code here
End if

Then close the socket again. 

Close socket

I find this to be the most reliable way to check a connection. I may not have internet, but the host may not be on the internet it may be local. Also, sockets will always work whereas ICMP can be blocked by a firewall. And simply trying to connect to a host will, as you have noticed bring timeouts into play. 

Bob S

> On Jul 13, 2023, at 11:26 PM, Ludovic THEBAULT via use-livecode <use-livecode at> wrote:
> Hello,
> I use this code to check is there is an internet connection :
> tsNETSETTIMEOUTS 60,0,2000,60000,5,1000
> put tsNetHeadSync("", tHeaders, tResult, tBytes) into tRecvHeaders
>   if tResult begins with "tsneterr:" then
>      return false 
>   else
>      return true 
>   end if
> But the setting for the timeout of tsNETSETTIMEOUTS is not active, I always have a 30 seconds timeout.
> Is there an other settings ?
> Thanks.
> _______________________________________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

More information about the use-livecode mailing list