예제 #1
0
        public void PortAvailability()
        {
            IDuplexInputChannel anInputChannel1 = MessagingSystemFactory.CreateDuplexInputChannel("tcp://[::1]:8044/");
            IDuplexInputChannel anInputChannel2 = MessagingSystemFactory.CreateDuplexInputChannel("tcp://127.0.0.1:8044/");

            try
            {
                anInputChannel1.StartListening();
                anInputChannel2.StartListening();

                Console.WriteLine("Available IP addresses:");
                string[] anAvailableIpAddresses = TcpMessagingSystemFactory.GetAvailableIpAddresses();
                foreach (string anIpAddress in anAvailableIpAddresses)
                {
                    Console.WriteLine(anIpAddress);
                }

                bool aResult = TcpMessagingSystemFactory.IsPortAvailableForTcpListening("tcp://[::1]:8044/");
                Assert.IsFalse(aResult);

                aResult = TcpMessagingSystemFactory.IsPortAvailableForTcpListening("tcp://0.0.0.0:8044/");
                Assert.IsTrue(aResult);
            }
            finally
            {
                anInputChannel1.StopListening();
                anInputChannel2.StopListening();
            }
        }