Exemple #1
0
        public void TestTcpChannel()
        {
            BaseChannel tcp = new TcpChannel();

            Assert.AreEqual(tcp.Open(), true);
            Assert.AreEqual(tcp.GetState(), ChannelState.Opened);

            // 00 02 00 00 00 05 06 03 02 00 00

            byte[] a       = new byte[] { 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x0A, 0x03, 0x00, 0x0D, 0x00, 0x01 };
            int    i       = 0;
            int    success = 0;

            while (true)
            {
                if (i == 100)
                {
                    return;
                }

                tcp.Write(a);
                byte[] buf = tcp.Read(256);
                if (buf.Length == 11)
                {
                    success++;
                }
                i++;
                Console.WriteLine(BitConverter.ToString(buf, 0).Replace("-", string.Empty).ToUpper());
            }
        }
Exemple #2
0
        private static IChannel <StringMessage> StartSecondInstance()
        {
            var channel = new TcpChannel <StringMessage>(new TcpEndpointData(IPAddress.Loopback, 2000),
                                                         new StringMessageSerializer(),
                                                         ChannelSettings.GetDefault(),
                                                         GetChatConnectionSettings(),
                                                         null);

            channel.Open();
            return(channel);
        }