[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Determining Internet Connection

Posted on 2004-09-07
3
Medium Priority
?
262 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
[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
  • 2
3 Comments
 
LVL 41

Expert Comment

by:graye
ID: 12002515
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

656 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