DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sun, 19 Aug 2007 14:46:03 -0700,    posted on: microsoft.public.dotnet.framework        back       

Thread Index
  1    Robert R. Richter am
          2    Peter Duniho
          3    (Charles Wang[MSFT])


Dual Mode Sockets on XP and Vista - need help from MS !   
I am using Dual Mode Sockets on Vista - runs fine so far...

I have used the information provided in this article => 
http://blogs.msdn.com/wndp/archive/2006/10/24/creating-ip-agnostic-applications-part-2-dual-mode-sockets.aspx

So I have the following code in my App.

System.Net.IPEndPoint localEndPoint = new 
System.Net.IPEndPoint(System.Net.IPAddress.IPv6Any, 5120);

System.Net.Sockets.Socket listener = new 
System.Net.Sockets.Socket(System.Net.Sockets.AddressFamily.InterNetworkV6, 
System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp);

listener.SetSocketOption(System.Net.Sockets.SocketOptionLevel.IPv6, 
(System.Net.Sockets.SocketOptionName)27, 0);

Never figured out what '27' as SocketOptions mean - just used the Code in 
the article of the link above...

Works great on Vista (tested on x86 Business), but when I run the App. under 
WinXP (SP2), I get an error with this SocketOption !!

I have installed IPv6 support (installed the Protocol via 
ControlPanel->Networking, selected my NIC and Properties, clicked 'install' 
and added the IPv6 protocol), but I don't know if there is something more to 
do (configure?) - I cannot click on Properties when the IPv6 Protocol is 
selected in the NIC's properties dialog!

Questions: why doesn't this code work under XP? do I have to configure 
(bind?) the IPv6 protocol to IPv4 (I think this is automatically done on 
Vista?!) and how?

Thank you in advance,
Robert
Date:Sun, 19 Aug 2007 14:46:03 -0700   Author:  

Re: Dual Mode Sockets on XP and Vista - need help from MS !   
Robert R. Richter wrote:

> listener.SetSocketOption(System.Net.Sockets.SocketOptionLevel.IPv6, 
> (System.Net.Sockets.SocketOptionName)27, 0);
> 
> Never figured out what '27' as SocketOptions mean - just used the Code in 
> the article of the link above...


As the article itself explains: "27 is equivalent to IPV6_V6ONLY socket 
option".  The article also mentions that this option is new to the 
Windows Vista network stack, and that the technique described in the 
article only work on the new network stack, which supports dual-mode 
sockets.


> Works great on Vista (tested on x86 Business), but when I run the App. under 
> WinXP (SP2), I get an error with this SocketOption !!


Not surprising, since as near as I can tell from the article, the 
technique described is not supported on network implementations prior to 
  Vista.


> I have installed IPv6 support (installed the Protocol via 
> ControlPanel->Networking, selected my NIC and Properties, clicked 'install' 
> and added the IPv6 protocol), but I don't know if there is something more to 
> do (configure?) - I cannot click on Properties when the IPv6 Protocol is 
> selected in the NIC's properties dialog!
> 
> Questions: why doesn't this code work under XP? do I have to configure 
> (bind?) the IPv6 protocol to IPv4 (I think this is automatically done on 
> Vista?!) and how?


It seems to me that the reason the code doesn't work under XP is that 
it's not supposed to.

As far as the other answers, I have very little experience with IPv6, 
but my impression is that you have to explicitly support it in your own 
application on XP.  There's no such thing as a dual-mode socket in XP, 
even if you have IPv6 support installed.

I'm even less clear on the configuration for IPv6 under XP, but assuming 
your PC is using IPv6, I doubt that the exact configuration would affect 
whether your application can use an IPv6 address, assuming you otherwise 
have support for that.  You may have to go the "IPv4 mapped address" 
route, if there's no explicit IPv6 support in the API.  Sorry about my 
lack of experience with respect to IPv6...it's probably an easy question 
to answer for someone who has actually done it before.  :)

Pete
Date:Sun, 19 Aug 2007 17:49:10 -0700   Author:  

RE: Dual Mode Sockets on XP and Vista - need help from MS !   
Hi Robert,
I unerstand that your dual mode socket server program worked fine on 
Windows Vista, however failed to work on Windows XP.
If I have misunderstood, please let me know.

Yes, as Pete mentioned,  the value 27 in your code means IPV6_V6ONLY 
(defined in ws2ipdef.h in Vista SDK) which is only supported on Windows 
Vista. You may refer to:
IPPROTO_IPV6 Socket Options
http://msdn2.microsoft.com/en-us/library/ms738574.aspx

On Windows XP or Windows 2003, to support both IPv4 and IPv6, you need to 
create two sockets to do this, one for IPv6, the other for IPv4. Please 
refer to the following article:
Dual-Stack Sockets
http://msdn2.microsoft.com/en-us/library/bb513665.aspx

For example:
     private void button1_Click(object sender, EventArgs e)
        {
            Thread tv6 = new Thread(new ThreadStart(StartListenV6));
            Thread tv4 = new Thread(new ThreadStart(StartListenV4));
            tv6.Start();
            tv4.Start();
            MessageBox.Show("Started");
        }

        void StartListenV6()
        {
            Socket listenerv6 = new Socket(AddressFamily.InterNetworkV6, 
SocketType.Stream, ProtocolType.Tcp);
            listenerv6.Bind(new IPEndPoint(IPAddress.IPv6Any, 10080));
            listenerv6.Listen(0);
            while (true)
            {
                Socket socket = listenerv6.Accept();
                byte[] b = new byte[11];
                int len;
                while ((len = socket.Receive(b)) != 0)
                {
                    System.Console.WriteLine("RX: " + 
System.Text.ASCIIEncoding.ASCII.GetString(b, 0, len));
                    b = new byte[11];
                }
                socket.Close();
            }

        }

        void StartListenV4()
        {
            Socket listenerv4 = new Socket(AddressFamily.InterNetwork, 
SocketType.Stream, ProtocolType.Tcp);
            listenerv4.Bind(new IPEndPoint(IPAddress.Any, 10080));
            listenerv4.Listen(0);
            while (true)
            {
                Socket socket = listenerv4.Accept();
                byte[] b = new byte[11];
                int len;
                while ((len = socket.Receive(b)) != 0)
                {
                    System.Console.WriteLine("RX: " + 
System.Text.ASCIIEncoding.ASCII.GetString(b, 0, len));
                    b = new byte[11];
                }
                socket.Close();
            }
        }

Hope this helps. If you have any other questions or concerns, please feel 
free to let us know. Have a good day!

Best regards,
Charles Wang
Microsoft Online Community Support
=====================================================
When responding to posts, please "Reply to Group" via 
your newsreader so that others may learn and benefit 
from this issue. 
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights. 
======================================================
Date:Mon, 20 Aug 2007 09:16:13 GMT   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us