Click here to Skip to main content
15,894,343 members
Articles / Desktop Programming / MFC

How to test the reachability of a VPN-Connection?

Rate me:
Please Sign up or sign in to vote.
3.30/5 (8 votes)
15 May 20042 min read 112.8K   2.4K   22  
Program to test the availability of hosts in a network on the basis of ICMP-Pings.
'modified by Thomas Fischer 04/2004 (http://www.thomas-fischer.org)
Imports System.Net
Imports System.Net.Dns
Public Class clsIP
    Public Function GetLocalHostIP() As String

        Dim objAddress As IPAddress
        Dim sAns As String

        Try

            objAddress = New IPAddress( _
              GetHostByName(GetLocalHostName).AddressList(0).Address)
            sAns = objAddress.ToString


        Catch ex As Exception
            Debug.WriteLine(ex.Message)
            sAns = ""
        End Try

        Return sAns

    End Function

    Public Function GetLocalHostName() As String
        Return GetHostName()
    End Function

    Public Function IPToHostName(ByVal IPAddress As String) _
          As String

        Dim objEntry As IPHostEntry
        Dim sAns As String
        Try
            objEntry = Resolve(IPAddress)
            sAns = objEntry.HostName
        Catch ex As Exception

            sAns = ""
        End Try

        Return sAns

    End Function

    Public Function HostNameToIP(ByVal Host As String) As String
        Dim objAddress As IPAddress
        Dim sAns As String

        Try
            objAddress = New IPAddress(GetHostByName( _
               Host).AddressList(0).Address)
            sAns = objAddress.ToString
        Catch
            sAns = ""
        End Try
        Return sAns


    End Function
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Engineer
Germany Germany
Thomas is interested in technical programming, networking and security technologies.

Currently he's studying at a german university

Comments and Discussions