Solved

how can i test a internet link?

Posted on 2011-03-20
7
285 Views
Last Modified: 2012-05-11
I have a form that may test if the internet and local link is activ. How can i do that?
thanks
0
Comment
Question by:luciliacoelho
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 42

Expert Comment

by:pcelba
ID: 35177699
You may use code from this link: http://fox.wikis.com/wc.dll?Wiki~HowtoPingRemoteSite

The "ping" will tell if you are connected and the second source will test DNS availability.

Many more similar routines exist.
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 35178260
I did it like this. I create a hidden webbrowser in a class and check if google or any other website opens.

FUNCTION IsInternetConnectionAvailable
WITH oWebBrowser
      .Navigate2("http://www.google.com")
      DO WHILE .ReadyState <> 4 && Wait till it opens
      ENDDO
ENDWITH
RETURN "google" $ LOWER(oWebBrowser.Document.body.innerText)
0
 
LVL 27

Expert Comment

by:CaptainCyril
ID: 35178292
I forgot to add the class and the initiation to the above.

DEFINE CLASS WebBrowser AS OLECONTROL
      OLEClass = "Shell.Explorer"
ENDDEFINE

FUNCTION IsInternetConnectionAvailable
LOCAL oWebBrowser
oWebBrowser = CreateObject("WebBrowser")
WITH oWebBrowser
      .Navigate2("http://www.google.com")
      DO WHILE .ReadyState <> 4 && Wait till it opens
      ENDDO
ENDWITH
RETURN "google" $ LOWER(oWebBrowser.Document.body.innerText)

0
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 35179458
You may use this: http://msdn.microsoft.com/en-us/library/aa384346%28VS.85%29.aspx

#DEFINE FLAG_ICC_FORCE_CONNECTION  1

DECLARE INTEGER InternetCheckConnection IN wininet;
    STRING lpszUrl, INTEGER dwFlags, INTEGER dwReserved
 
? InternetCheckConnection("http://www.google.com",FLAG_ICC_FORCE_CONNECTION,0)

Open in new window


You can also check general availability of Internet via InternetCheckConnection(NULL,FLAG_ICC_FORCE_CONNECTION,0)

Bye, Olaf.
0
 

Author Comment

by:luciliacoelho
ID: 35412888
i try the CaptainCyril solution, but i put the code in a VFP method, and the result is an error. How can i creat the class?
thanks
0
 
LVL 27

Accepted Solution

by:
CaptainCyril earned 500 total points
ID: 35413502
Yes I am sorry. The webbrowser has to be in a form or container to work.

? IsInternetConnectionAvailable()

DEFINE CLASS WebBrowser AS OLECONTROL
      OLEClass = "Shell.Explorer"
ENDDEFINE

FUNCTION IsInternetConnectionAvailable
LOCAL oWebBrowserForm
oWebBrowserForm = CREATEOBJECT("WebBrowserForm")
WITH oWebBrowserForm.WebBrowser
      .Navigate2("http://www.google.com")
      DO WHILE .ReadyState <> 4 && Wait till it opens
      ENDDO
ENDWITH
RETURN "google" $ LOWER(oWebBrowserForm.WebBrowser.Document.body.innerText)

DEFINE CLASS WebBrowserForm AS FORM
      ShowWindow = 2
      Visible = .F.

      ADD OBJECT WebBrowser AS WebBrowser
ENDDEFINE
0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 35417285
luciliacoelho.

you can't put defines into a method, this code needs to be in a PRG or you redo that with visual classes in vcxes.

Bye. Olaf.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question