Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
if (!Socket.SupportsAddressFamily(AddressFamily.InterNetworkV6)) { Console.WriteLine("IPv6 not supported on this platform"); }
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); AddressFamily addressFamily = socket.AddressFamily;In this example, we create a new socket object, set its AddressFamily to InterNetwork, and then retrieve the value using the AddressFamily property. Package library: System.Net.Sockets (in the System.dll assembly)