Return to Snippet

Revision: 13915
at May 12, 2009 10:29 by blackf0rk

Initial Code
Public Function GotInternet() As Boolean
        Dim req As System.Net.HttpWebRequest
        Dim res As System.Net.HttpWebResponse
        GotInternet = False
            req = CType(System.Net.HttpWebRequest.Create(""), System.Net.HttpWebRequest)
            res = CType(req.GetResponse(), System.Net.HttpWebResponse)
            If res.StatusCode = System.Net.HttpStatusCode.OK Then
                GotInternet = True
            End If
        Catch weberrt As System.Net.WebException
            GotInternet = False
        Catch except As Exception
            GotInternet = False
        End Try
    End Function

Initial URL

Initial Description
This is a simple function to test for an internet connection. Originally grabbed from "devbuzz" at the devbuzz forums (see link) and now modified for VB.NET 3.5

Initial Title
Test for Internet Connection

Initial Tags

Initial Language