IP Address

kurt69

Well-known member
Joined
Jan 17, 2006
Messages
78
Location
Australia
Programming Experience
Beginner
Hey working on some networking stuff at the moment and on my form there is 2 labels, one for a LAN ip address and one for a WAN (internet) address.

For the internet address I'm using mcwtech's webservice. (read this: http://vbdotnetforums.com/showthread.php?t=7644)

This is my code:
VB.NET:
Dim ipEntry As IPHostEntry = Dns.GetHostByName(Environment.MachineName)
        Dim IpAddr As IPAddress() = ipEntry.AddressList
        Dim i As Integer
        If IPAddress.IsLoopback(IpAddr(0)) = True Then
            lblLAN.Text = IpAddr(1).ToString()
        Else
            lblLAN.Text = IpAddr(0).ToString()
        End If
        Dim ipService As New com.mcwtech.www.AddressInfo
        lblWAN.Text = ipService.GetAddress
Just wandering if anyone has any ideas on what I could do in the instance the user has no way of connecting to that website (firewall/no connection/etc). Some example code would be a bonus :D

Edit: Currently I'm just doing a timeout, (timer that fires after 20 seconds and changes labeltext to "Error")
 
Back
Top