ASP.NET Tips: Printing an IP Address
So while looking through a dump, you will sometimes come across an IP Address. For example, the System.Net.IPAddress:
If you look at this output, you can see that we have the address in the m_Address field, but what is 1895899146? This is where the function !printipaddress comes into play. This is in the clr10\sos version of sos and works on 1.x versions of .NET. All you have to do is pass it the System.Net.IPAddress object or the m_Address value.
Very easy then to get the IP Address that we are dealing with. If you really want to do this by hand, you can do the following. Convert it to Hex, then break it up into bytes and look at them in reverse order.
So this number in hex would be 0x7101200a. So breaking that up would be 71 01 20 0a. Reversing them would be 0a 20 01 71. And now back to decimal gives you 10 32 1 113 (the IP Address we see above).
UPDATE
For .NET 2.0 versions, there is an alternative method to getting the IP Address. There is a member m_ToString and if you !dumpobj that address, you will see the IP address. Hope that helps those of you using the newer version of .NET.
Comments
Anonymous
April 29, 2008
You've been kicked (a good thing) - Trackback from DotNetKicks.comAnonymous
April 29, 2008
Ever try looking at the IP Address from this object?  It isn’t very easy to see what the actualAnonymous
April 29, 2008
There's also some IPAddress extensions out there to help you get some more ip info for the Request object. check it out: http://www.codeplex.com/IPAddressExtensions hth.Anonymous
April 30, 2008
Thanks PK. That is also very helpful.