Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / May 2004

Tip: Looking for answers? Try searching our database.

IPAddress.Address is obsolete

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael Riggio - 07 May 2004 19:58 GMT
Does anyone know why this property is obsolete?  Also, is there an
alternative available?
William Ryan eMVP - 07 May 2004 20:25 GMT
> Does anyone know why this property is obsolete?
Not specifically, but usually it's b/c they build in new funcionality and
the obsolete stuff no longer works due to a change in a dependency or
doesn't fit in the model.  I'll see if I can get you a real answer to this
one b/c this is just a guess on my part
Also, is there an
> alternative available?
Something like this:

Dim Ip_Address As IPHostEntry = Dns.Resolve("205.128.215.120")

MessageBox.Show(Ip_Address.HostName)
Michael Riggio - 07 May 2004 20:31 GMT
Thanks for taking the time to perform a test or two for me.  Also,
concerning your alternative:
IPHostEntry contains a collection of IPAddress objects, so I think I'm soft
of in the same situation.  The application I'm working on needs to display
the list of ipaddresses for each hostname, so I would definitely need to
iterate through that collection..

> > Does anyone know why this property is obsolete?
> Not specifically, but usually it's b/c they build in new funcionality and
[quoted text clipped - 8 lines]
>
>  MessageBox.Show(Ip_Address.HostName)
William Ryan eMVP - 07 May 2004 20:59 GMT
Michael:

I wish I knew a better answer but I'm a relative newbie to network
programming.

This will walk you through it though:

> Thanks for taking the time to perform a test or two for me.  Also,
> concerning your alternative:
[quoted text clipped - 15 lines]
> >
> >  MessageBox.Show(Ip_Address.HostName)
William Ryan eMVP - 07 May 2004 20:59 GMT
Ooops

For Each add As IPAddress In Ip_Address.AddressList

Next

> Thanks for taking the time to perform a test or two for me.  Also,
> concerning your alternative:
[quoted text clipped - 15 lines]
> >
> >  MessageBox.Show(Ip_Address.HostName)
Daniel O'Connell [C# MVP] - 07 May 2004 22:55 GMT
> Does anyone know why this property is obsolete?  Also, is there an
> alternative available?

Docs say to use the GetAddressBytes method to get the address as binary
data. You should also be able to use IPAddress.ToString to get the address
in a textual notation.
Jay B. Harlow [MVP - Outlook] - 08 May 2004 23:49 GMT
Michael,
In addition to the other's comments:

My understanding is IPAddress.Address is obsolete as it does not support
IPv6. (internet addresses longer then 32bits).

As Daniel suggested, the GetAddressBytes call supports addresses longer then
32bits!

Hope this helps
Jay

> Does anyone know why this property is obsolete?  Also, is there an
> alternative available?
Locke Nash Cole - 10 May 2004 08:34 GMT
Here is a tool I call IPLookup I wrote in .NET (console app) that should
show you how to use the IP lookup stuff...

Imports System.Net
Imports System.Net.Sockets
Imports System.Reflection.Assembly

Module modCore
   Sub Main(ByVal cmdArgs() As String)

       Dim iTotalParms As Integer = 0
       iTotalParms = (UBound(cmdArgs) + 1)

       Console.WriteLine("{0} {1}.{2}.{3} Copyright (C) 2004 Joseph N.
Stackhouse", _
       GetExecutingAssembly.GetName.Name, _
       GetExecutingAssembly.GetName().Version.Major.ToString(), _
       GetExecutingAssembly.GetName().Version.Minor.ToString(), _
       GetExecutingAssembly.GetName().Version.Build.ToString())

       Console.WriteLine()

       If (iTotalParms) <> 1 Then
           Console.WriteLine("Usage: {0} <hostname>",
GetExecutingAssembly.GetName.Name)
           End
       End If

       Dim iTotalResults As Integer = 0
       Dim sIPs() As String
       Dim sNames() As String

       Dim DNSLookup As Dns
       Dim HostLookup As Dns

       Dim IPResult As New IPHostEntry

       Try
           IPResult = DNSLookup.GetHostByName(cmdArgs(0))
       Catch ex As SocketException
           Console.WriteLine("Could not resolve [{0}]:", cmdArgs(0))
           Console.WriteLine()
           Console.WriteLine(ex.Message)
           End
       Catch ex As System.ArgumentOutOfRangeException
           Console.WriteLine("Cannot process your request as one or more
segments of the address you specified exceed the maximum length allowed")
           End
       End Try

       iTotalResults = UBound(IPResult.AddressList)

       Console.WriteLine("Found a total of {0} addresses for [{1}]:",
(iTotalResults + 1).ToString, cmdArgs(0))
       Console.WriteLine()

       ReDim sIPs(iTotalResults)
       ReDim sNames(iTotalResults)

       Dim i As Integer = 0

       Do While i <= UBound(IPResult.AddressList)
           sIPs(i) = (IPResult.AddressList(i).ToString())

           Try
               sNames(i) =
HostLookup.GetHostByAddress(sIPs(i)).HostName.ToString
           Catch ex As Sockets.SocketException
               If sNames(i) = vbNullString Then sNames(i) = "none"
           End Try

           Console.WriteLine("{0}.{1}{2}{3}({4})", (i + 1).ToString, vbTab,
sIPs(i), vbTab, sNames(i))
           i += 1
       Loop

   End Sub
End Module

Alternatively you can download it from Planet Source Code at:

http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=1287

-L

> Michael,
> In addition to the other's comments:
[quoted text clipped - 10 lines]
> > Does anyone know why this property is obsolete?  Also, is there an
> > alternative available?
Michael Riggio - 17 May 2004 22:23 GMT
Hi Jay,
     So, the IPAddress type will support IPv6, but the Address property
doesn't.  To get around that you're suggesting using the
IPAddress.GetAddressBytes method?  So, in theory, I could derive from
IPAddress and include my own Address property that supports IPv6, and
everyone would be happy?

Thanks!
-Michael

> Michael,
> In addition to the other's comments:
[quoted text clipped - 10 lines]
> > Does anyone know why this property is obsolete?  Also, is there an
> > alternative available?
Daniel O'Connell [C# MVP] - 17 May 2004 22:51 GMT
> Hi Jay,
>      So, the IPAddress type will support IPv6, but the Address property
> doesn't.  To get around that you're suggesting using the
> IPAddress.GetAddressBytes method?  So, in theory, I could derive from
> IPAddress and include my own Address property that supports IPv6, and
> everyone would be happy?

Only until a new address format comes around or you have someone who needs
to deal with both without knowing which he's handling.

Keeping everyone happy is about as easy as counting the sand in the sahara
using nothing but a hippo and three bananas.

> Thanks!
> -Michael
[quoted text clipped - 14 lines]
>> > Does anyone know why this property is obsolete?  Also, is there an
>> > alternative available?
Jay B. Harlow [MVP - Outlook] - 18 May 2004 01:48 GMT
Michael,
What would your address property provide that is not provided by
GetAddressBytes?

The "problem" with your theory is that Address is not overridable & to
change what it returns you would need to "shadow" it anyway (new in C#),
once you "shadow" it, the property will not function polymorphically, if I
assign one of your DerivedIPAddress objects to an IPAddress variable, the
normal Address property will be exposed...

I'm happy using IPAddress.GetAddressBytes or IPAddress.ToString.

Hope this helps
Jay

> Hi Jay,
>       So, the IPAddress type will support IPv6, but the Address property
[quoted text clipped - 21 lines]
> > > Does anyone know why this property is obsolete?  Also, is there an
> > > alternative available?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.