Dual mode socket
Dual mode socket is a IPv6 socket which is also compatible with IPv4. To acheive this we need to make "IPV6_V6Only" socket option to false. In C# this can be acheived by the following code..
IPEndPoint ipEndPoint = new IPEndoint(IPAddress.Any, port);
Socket socket = new Socket(ipEndPoint.AddressFamily, SocketType.Stream, ProtocolType.IP);
socket.SetSocketOption(SocketOptionLevel.IPv6, (SocketOptionName)27,0);
//27 is the enumeration value for "IPV6_V6Only"
socket.Bind(ipEndPoint);
socket.Listen(backLog);
IPEndPoint ipEndPoint = new IPEndoint(IPAddress.Any, port);
Socket socket = new Socket(ipEndPoint.AddressFamily, SocketType.Stream, ProtocolType.IP);
socket.SetSocketOption(SocketOptionLevel.IPv6, (SocketOptionName)27,0);
//27 is the enumeration value for "IPV6_V6Only"
socket.Bind(ipEndPoint);
socket.Listen(backLog);
Comments
Post a Comment