Example #1
0
        public void EnhancedSocket_CreateDatagramPair()
        {
            for (int i = 0; i < 1000; i++)
            {
                EnhancedSocket sock0 = null;
                EnhancedSocket sock1 = null;
                int            port0, port1;

                try
                {
                    EnhancedSocket.CreateDatagramPair(IPAddress.Any, out sock0, out sock1);

                    port0 = ((IPEndPoint)sock0.LocalEndPoint).Port;
                    port1 = ((IPEndPoint)sock1.LocalEndPoint).Port;
                }
                finally
                {
                    if (sock0 != null)
                    {
                        sock0.Close();
                    }

                    if (sock1 != null)
                    {
                        sock1.Close();
                    }
                }
            }
        }