private void CreateTCPListener()
{
try
{
if (System.Environment.OSVersion.Version.Major < 6)
{
// ipv4 only (older than Vista):
this.tcpListener = new TcpListener(IPAddress.Any, port);
}
else
{
// Dual stack: accept ipv6 and ipv4 connections
this.tcpListener = new TcpListener(IPAddress.IPv6Any, port);
tcpListener.Server.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, false);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}