/// <summary>
 /// Returns IP addresses assigned to the device which can be used for listening.
 /// </summary>
 /// <returns>array of available addresses</returns>
 public static string[] GetAvailableIpAddresses()
 {
     using (EneterTrace.Entering())
     {
         return(TcpMessagingSystemFactory.GetAvailableIpAddresses());
     }
 }
예제 #2
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();
            }
        }