467,915 Members | 1,558 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,915 developers. It's quick & easy.

System.Uri and IPv6 with embedded IPv4

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?
Jan 2 '08 #1
  • viewed: 2076
Share:
1 Reply
I have reposted this in the .NET Framework discusson board
(http://msdn.microsoft.com/newsgroups...&lang=en&cr=US)

"William Randlett" wrote:
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?
Jan 5 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by John Burton | last post: by
reply views Thread by Carl-Johan Kjellander | last post: by
reply views Thread by Addam | last post: by
2 posts views Thread by prabhuram.k | last post: by
3 posts views Thread by Pramod TK | last post: by
2 posts views Thread by Valerie Hough | last post: by
8 posts views Thread by Giampaolo Rodola' | last post: by
14 posts views Thread by Simon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.