Revisando este post en donde Marek comparte esta funcion, cree esta variante.
En cierto momento queremos saber si hay conexion a Internet.
Espero les sirva.
---------------------------------------------------------------------------
Hello
Reviewing this post where Marek shares this function, create this variant.
At some point we want to know if there is internet connection.
I hope they serve.
http://hmgforum.com/viewtopic.php?f=12& ... ate#p28507
Code: Select all
* MsgBox( IF( HayInternet( ), "INTERNET: Connected ...", "INTERNET: Not Connected..." ) )
FUNCTION HayInternet( )
LOCAL oCon, oUrl, lRet := .f.
LOCAL oOldErrorHandle, cUrl, cLocalFileName
cUrl := "http://www.microsoft.com/es-mx/default.aspx"
cLocalFileName := System.TempFolder+"InternetOK.txt"
IF FILE( cLocalFileName )
Ferase( cLocalFileName )
ENDIF
oOldErrorHandle:= ErrorBlock({|e| break(e)})
BEGIN SEQUENCE
oUrl := tURL():New( cUrl )
oCon := TipClientHttp():New( oUrl )
oCon:nConnTimeout := 20000
IF oCon:Open( cUrl )
oCon:WriteAll( cLocalFileName )
oCon:Close()
IF FILE( cLocalFileName )
lRet := .T.
*MsgBox( "Connected..." )
ELSE
lRet := .F.
ENDIF
ELSE
lRet := .f.
END
RECOVER
*MSGSTOP("Connection with server couldn't be completed")
END SEQUENCE
ErrorBlock(oOldErrorHandle)
RETURN( lRet )