Solved

Determining Internet Connection

Posted on 2004-09-07
3
250 Views
Last Modified: 2010-04-23
Hi All,

How do I determine whether an application has access to the internet, or that a dial up connection has been established?

Running on a server, the app needs to send out emails, but at the moment, the server only has a temporary dial up connection. I need to determine that the connection is active before trying to send emails.

Any ideas???
0
Comment
Question by:finster
  • 2
3 Comments
 
LVL 41

Expert Comment

by:graye
ID: 12002515
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 50 total points
ID: 12004617
Try this:

    Public Shared Function IsWebAccessible() As Boolean
        Dim hwrRequest As System.Net.HttpWebRequest
        Dim hwrResponse As System.Net.HttpWebResponse

        Dim strUrl As String = "http://www.microsoft.com/"
        Dim bConnected As Boolean = False

        Try
            hwrRequest = CType(System.Net.WebRequest.Create(strUrl), System.Net.HttpWebRequest)
            hwrResponse = CType(hwrRequest.GetResponse(), System.Net.HttpWebResponse)

            If hwrResponse.StatusCode = System.Net.HttpStatusCode.OK Then
                bConnected = True
            End If

        Catch we As System.Net.WebException
            bConnected = False
        Catch ex As Exception
            bConnected = False
        Finally
            hwrRequest = Nothing
            hwrResponse = Nothing
        End Try

        Return bConnected
    End Function
0
 
LVL 41

Expert Comment

by:graye
ID: 12083391
Just curious.... won't that test actually dial the internet if you have "dial on demand" settings for your modem?   Wouldn't that defeat the purpose of testing if you were already connected?
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now