예제 #1
0
        public void ConnectTest()
        {
            var worker = new TcpWorker();
            Action a = () =>
            {
                worker.Listen(3000);

            };
            var r = a.BeginInvoke(null, null);

            var clientWorker = new TcpWorker();
            clientWorker.Join("127.0.0.1",3000);
            r.AsyncWaitHandle.WaitOne();
            worker.Reset();
            clientWorker.Reset();
        }
예제 #2
0
        public void ConnectTest()
        {
            var    worker = new TcpWorker();
            Action a      = () =>
            {
                worker.Listen(3000);
            };
            var r = a.BeginInvoke(null, null);

            var clientWorker = new TcpWorker();

            clientWorker.Join("127.0.0.1", 3000);
            r.AsyncWaitHandle.WaitOne();
            worker.Reset();
            clientWorker.Reset();
        }
예제 #3
0
        public void SendTest()
        {
            var worker = new TcpWorker();

            Action a = () =>
                           {
                               worker.Listen(3000);

                           };
            var r = a.BeginInvoke(null, null);

            var clientWorker = new TcpWorker();
            clientWorker.Join("127.0.0.1", 3000);

            r.AsyncWaitHandle.WaitOne();

            worker.RecieveMessagesEvent += worker_RecieveMessagesEvent;
            clientWorker.RecieveMessagesEvent += clientWorker_RecieveMessagesEvent;

            clientWorker.SendMessage("test");
            worker.SendMessage("test2");
            Thread.Sleep(500);
            worker.SendMessage("test2-1");
               // Thread.Sleep(500);
            worker.SendMessage("test2-2");

            //Thread.Sleep(500);
            worker.SendMessage("test2-2");
            //Thread.Sleep(500);
            worker.SendMessage("test2-2");

            clientWorker.SendMessage("test1");

            worker.SendMessage("test5");

            clientWorker.SendMessage("test4");
            worker.SendMessage("test3");

            Thread.Sleep(1000);
            worker.Reset();
            clientWorker.Reset();

            //Thread.Sleep(1000);
        }
예제 #4
0
        public void SendTest()
        {
            var worker = new TcpWorker();

            Action a = () =>
            {
                worker.Listen(3000);
            };
            var r = a.BeginInvoke(null, null);

            var clientWorker = new TcpWorker();

            clientWorker.Join("127.0.0.1", 3000);

            r.AsyncWaitHandle.WaitOne();

            worker.RecieveMessagesEvent       += worker_RecieveMessagesEvent;
            clientWorker.RecieveMessagesEvent += clientWorker_RecieveMessagesEvent;

            clientWorker.SendMessage("test");
            worker.SendMessage("test2");
            Thread.Sleep(500);
            worker.SendMessage("test2-1");
            // Thread.Sleep(500);
            worker.SendMessage("test2-2");

            //Thread.Sleep(500);
            worker.SendMessage("test2-2");
            //Thread.Sleep(500);
            worker.SendMessage("test2-2");

            clientWorker.SendMessage("test1");

            worker.SendMessage("test5");

            clientWorker.SendMessage("test4");
            worker.SendMessage("test3");

            Thread.Sleep(1000);
            worker.Reset();
            clientWorker.Reset();

            //Thread.Sleep(1000);
        }