Home » .Net Framework

TCPClient, TCPListener and IPv6

I basically use this code on server:

listener = New TcpListener(IPAddress.Any, SettingsAPI.ServerPort)

and this code on client:

tcpclient = New TcpClient(Server.Connection.Address, Server.Connection.Port)
It seems like this code does not work in IPv6 environment. What do I need to do to support this?


3 Answers Found


Answer 1


Answer 2

Will that be backwards compatible (work on IPv4 as well) or do I have to have one listner on IPv4 and one on IPv6?

Answer 3

On Vista and later one socket can do both protocols, but on XP one will need two sockets.  See http://blogs.msdn.com/b/wndp/archive/2006/10/24/creating-ip-agnostic-applications-part-2-dual-mode-sockets.aspx (and http://blogs.msdn.com/b/wndp/archive/2006/08/29/creating-ip-agnostic-applications--part--1.aspx

However one needs to configure the socket for dual-protocol use. So presumably one needs to do that before starting the listener, e.g.:

// 27 is equivalent to IPV6_V6ONLY socket option in the winsock snippet below
listener.Server.SetSocketOption(SocketOptionLevel.IPv6, (SocketOptionName)27, 0);


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure