Solved

Determining Internet Connection

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Word Template Mail merge with vb.net 4 56
Create XML 5 46
Get the selected ValueMember of Combobox 5 19
VB.NET Repostiory Pattern 7 0
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

919 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

20 Experts available now in Live!

Get 1:1 Help Now