示例#1
0
        public void Test_4()
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("In Test: " + System.Reflection.MethodBase.GetCurrentMethod());
            }

            ConnectionInfo connection = new ConnectionInfo();

            connection.Addr = "localhost";
            connection.Port = 7777;

            TCPMessageChannelAcceptor channelAcceptor1 = channelMngr.StartNewListener(connection);

            channelMngr.CloseAcceptor(channelAcceptor1);

            TCPMessageChannelAcceptor channelAcceptor2 = channelMngr.StartNewListener(connection);

            System.Net.IPHostEntry hostEntry = System.Net.Dns.GetHostEntry(connection.Addr);
            System.Net.IPAddress   ipAddress = System.Net.Dns.GetHostEntry(hostEntry.HostName).AddressList[0];

            Assert.AreEqual(channelAcceptor1.IsClosed, true);
            Assert.AreEqual(channelAcceptor2.IsClosed, false);
            Assert.AreEqual(channelAcceptor2.LocalEndPoint.ToString(), ipAddress + ":7777");

            channelMngr.DumpChannelsInfo();
            channelMngr.CloseAcceptor(channelAcceptor2);
            Assert.AreEqual(channelAcceptor2.IsClosed, true);
            channelMngr.DumpChannelsInfo();
        }
示例#2
0
        public void Test_1()
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("In Test: " + System.Reflection.MethodBase.GetCurrentMethod());
            }

            ConnectionInfo connection = new ConnectionInfo();

            connection.Addr = "localhost";
            connection.Port = 7777;

            TCPMessageChannelAcceptor channelAcceptor = channelMngr.StartNewListener(connection);

            Assert.AreEqual(channelAcceptor.IsClosed, false);

            channelAcceptor.Close();

            Assert.AreEqual(channelAcceptor.IsClosed, true);
        }