示例#1
0
        public void Test()
        {
            byte[] encryptionKey = new byte[16];
            Random.NextBytes(encryptionKey);

            Console.WriteLine("Starting server");
            DoubleServerHandler serverHandler = new DoubleServerHandler();
            DoubleServer        server        = new DoubleServer(serverHandler, 1, 1, Port);

            serverHandler.Server = server;

            Console.WriteLine("Starting client");
            DoubleClientHandler clientHandler = new DoubleClientHandler();
            DoubleClient        client        = new DoubleClient(clientHandler, encryptionKey, encryptionKey, Ip, Port);

            clientHandler.Client = client;
            client.Start();

            lock (client) {
                clientHandler.MaySend = true;
                Monitor.Pulse(client);
                Console.WriteLine("Main thread waiting");
                Monitor.Wait(client);
            }

            Console.WriteLine("Closing client");
            client.Close();
            Console.WriteLine("Closing server");
            server.Close();
        }
示例#2
0
 public void Stop()
 {
     _senderThread.Interrupt();
     _senderThread.Join();
     _server.Close();
 }