FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Least expensive way to know whether connected to internet
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

Least expensive way to know whether connected to internet

Posted: Fri Oct 07, 2011 03:20 AM
Hi guys,
If I want to know whether my pc has access to internet or not, would this be the least expensive but still safe way?
Code (fw): Select all Collapse
   function HasInternetAccess()
      LOCAL pSocket

      INetInit()

      pSocket := INetConnect( "www.google.com", 80 )

      lRet := !empty( INetAddress( pSocket ))

      INetClose( pSocket )
      INetCleanUp()
   RETURN


Thanks for any opinion.

I adapted it from xHarbour's INetAddress() documentation
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 883
Joined: Thu Dec 24, 2009 12:46 AM

Re: Least expensive way to know whether connected to internet

Posted: Fri Oct 07, 2011 03:26 AM
You can also use function IsInternet():

Code (fw): Select all Collapse
MsgInfo( IsInternet() )

=====>

Bayron Landaverry
xBasePHP.com
(215)2226600 Philadelphia,PA, USA
MayaBuilders@gMail.com
Guatemala

FWH25.06--Harbour 3.0.0--BCC7.7--UEstudio 10.10
Windows 10

FiveWin, One line of code and it's done...

Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM

Re: Least expensive way to know whether connected to internet

Posted: Fri Oct 07, 2011 03:34 AM

Thanks Bayron. I missed that :) So I'll just use IsInternet()

FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion