HighTechTalks DotNet Forums  

System.Uri and IPv6 with embedded IPv4

Dotnet General Discussions microsoft.public.dotnet.general


Discuss System.Uri and IPv6 with embedded IPv4 in the Dotnet General Discussions forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
William Randlett
 
Posts: n/a

Default System.Uri and IPv6 with embedded IPv4 - 01-02-2008 , 08:00 AM






The System.Uri class is not behaving as I expect when an IPv4 address is
embedded within an IPv6 address. The following test works fine, using IPv6
only:
[Test]
public void Uri_ShouldCreateValidUriFromSimpleIPv6Address()
{
Uri testUri = new Uri("http://[::1]:9050");
Assert.AreEqual(
"http://[0000:0000:0000:0000:0000:0000:0000:0001]:9050/",
testUri.ToString());
}

However, when I embed an IPv4 address, the Uri class begins converting the
address in a way that I do not expect:
public void Uri_ShouldCreateValidUriFromIPv4AddressEmbeddedWit hinIPv6Address()
[Test]
{
Uri testUri = new Uri("http://[::101.45.75.219]:9050");
Assert.AreEqual(
"http://[0000:0000:0000:0000:0000:0000:101.45.75.219]:9050/",
testUri.ToString());
}
TestCase 'Uri_ShouldCreateValidUriFromIPv4AddressEmbeddedWi thinIPv6Address'
failed:
String lengths differ. Expected length=58, but was length=54.
Strings differ at index 38.
expected: <"...p://[0000:0000:0000:0000:0000:0000:101.45.75.219]:9050/">
but was: <"...p://[0000:0000:0000:0000:0000:0000:652D:4BDB]:9050/">
--------------------------------------------------^

Am I missing something here?

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.