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
Solved

Determining Internet Connection

Posted on 2004-09-07
3
254 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 70

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 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