2007-08-03

Get IP Address By Net Class

This sample show How to get ip address by use net class.

Private Function IPAddresses(ByVal server As String) As String
Dim objArray As New ArrayList
Dim ip As String = String.Empty

Try

' Get server related information.
Dim heserver As System.Net.IPHostEntry = System.Net.Dns.GetHostEntry(server)

' Loop on the AddressList
Dim curAdd As System.Net.IPAddress
For Each curAdd In heserver.AddressList

ip = curAdd.ToString
Exit For

Next curAdd


Catch e As Exception
Debug.WriteLine("Exception: " + e.ToString())
End Try

Return ip

End Function 'IPAddresses

For this sample you can call that funciton by pass name parameter or url such as

IPAddresses("YourPCName")
IPAddresses("www.hotmail.com")
...
...

System.Net Namespace
The System.Net namespace provides a simple programming interface for many of the protocols used on networks today. The WebRequest and WebResponse classes form the basis of what are called pluggable protocols, an implementation of network services that enables you to develop applications that use Internet resources without worrying about the specific details of the individual protocols.

more detail

1 comment:

Anonymous said...

thanks....