473,788 Members | 2,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_ShouldCreat eValidUriFromSi mpleIPv6Address ()
{
Uri testUri = new Uri("http://[::1]:9050");
Assert.AreEqual (
"http://[0000:0000:0000: 0000:0000:0000: 0000:0001]:9050/",
testUri.ToStrin g());
}

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_ShouldCreat eValidUriFromIP v4AddressEmbedd edWithinIPv6Add ress()
[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.ToStrin g());
}
TestCase 'Uri_ShouldCrea teValidUriFromI Pv4AddressEmbed dedWithinIPv6Ad dress'
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
1 2495
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_ShouldCreat eValidUriFromSi mpleIPv6Address ()
{
Uri testUri = new Uri("http://[::1]:9050");
Assert.AreEqual (
"http://[0000:0000:0000: 0000:0000:0000: 0000:0001]:9050/",
testUri.ToStrin g());
}

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_ShouldCreat eValidUriFromIP v4AddressEmbedd edWithinIPv6Add ress()
[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.ToStrin g());
}
TestCase 'Uri_ShouldCrea teValidUriFromI Pv4AddressEmbed dedWithinIPv6Ad dress'
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2547
by: John Burton | last post by:
I'm not sure if this is a question about python socket support or sockets in general ... I have a socket server with which I want to accept incoming connections on ipv4 and ipv6. I've found that if I create the listening socket with sock = socket(AF_INET, SOCK_STREAM) it will accept connections on ipv4 (only) and if I create it with sock = socket(AF_INET6, SOCK_STREAM) it will accept connections with ipv6 (only)
0
1208
by: Carl-Johan Kjellander | last post by:
I have a problem. I want to use httplib to a site that has both IPv4 and IPv6 connectivity, hence it has both A and AAAA records. Is there a way to force httplib to use IPv6 only, or to at least try IPv6 before IPv4? As it is now, httplib always takes the IPv4 address first. If there isn't a way to do this, i.e. httplib always connects to the IPv4 address first, and there is now way to change that, who do I talk to about adding a...
2
3026
by: gregory_may | last post by:
First the research links: IPv6 spec (look for 'jumbo payload'): http://www.cs-ipv6.lancs.ac.uk/ipv6/documents/rfcs/archive/rfc1883.txt IPv6 Sample C# Client/Server http://www.codeproject.com/csharp/ipv6.asp I am developing an application where I need to broadcast information to clients. I have hit a 64K limit in UDP broadcasting. I am not exited
0
1419
by: Addam | last post by:
Anyone, I am writting a server that accepts a list of IPv4 and IPv6 address. The IPv4 address are padded with leading zeros. I belive this allows me to just point to the beging and run both IPv4 addresses and IPv6 address though the same conversion function. However, i am having a hard time finding a simple way to this. I do not want to communicate with the addresses so i would like to avoid setting up anything extra. So does anyone...
2
5819
by: prabhuram.k | last post by:
Can anybody know how to validate IPV4 and IPV6 address in PHP. I am using PHP 4.2.3 for some compatiability reason.
3
1858
by: Pramod TK | last post by:
Hello All, I have some queries related to python support for IPv6. Can you kindly clarify the doubts which I have - 1. Does python support IPv6? 2. Does it support setting of QoS flags? 3. Does it support tunneling of IPv6 on a IPv4 network? 4. If an IPv4 address is given, does it support this on a IPv6 network? If not can you kindly let me know, Are there any plans for supporting these features in future?
2
9432
by: Valerie Hough | last post by:
My app has so far only encountered IPv4 addresses and I use: Dns.GetHostByName( "someOtherComputer", portNumber ).AddressList. Can someone please point me to an example of how to turn this into an IPv6 address? Thanks in advance. Chris Hough
8
8949
by: Giampaolo Rodola' | last post by:
I'm not sure if this is a question about python programming, system administration or sockets in general... I have the FTP server in my signature to which I'd want to add IPv6 support. My hosting company provides me a common IPv4 address. I'd like to set up my workstation (Windows XP or Linux Debian, doesn't really matter) to temporarily use IPv6 for trying to add such feature to my library (I work on both Windows XP and Linux). Could...
14
9298
by: Simon | last post by:
Hi, is there a straight forward way of converting IPv4 to IPv6? I thought that it was just a matter of converting 32 bits to 128 bits, (by adding 96 leading 0s), but that does not seem right in some/most cases. For example, 127.0.0.1, (IPv4 localhost), does not convert ::1, (IPv6 localhost)
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.