Exemplo n.º 1
0
        static async Task TestStreams2()
        {
            (var s1, var s2) = ProducerConsumerStream.Create();

            var t1 = RunClient(s1);
            await Task.Delay(50);

            var t2 = RunServer(s2);

            await Task.WhenAll(t1, t2);
        }
Exemplo n.º 2
0
        private static async Task <(ClientHandler clientHandler, ServerHandler serverHandler)> StartOneAsync(X509Certificate2 cert, int messageSize)
        {
            (var s1, var s2) = ProducerConsumerStream.Create();

            var t1 = SslHelper.GetClientStream(s1);
            var t2 = SslHelper.GetServerStream(s2, cert);
            await Task.WhenAll(t1, t2);

            var clientHandler = new ClientHandler(t1.Result, messageSize);
            var serverHandler = new ServerHandler(t2.Result, messageSize);

            return(clientHandler, serverHandler);
        }
Exemplo n.º 3
0
        static void SslTest()
        {
            var cert = SslHelper.LoadCert();

            Stream s1, s2;

            (s1, s2) = ProducerConsumerStream.Create();

            Task <SslStream> t1 = SslHelper.GetClientStream(s1);
            Task <SslStream> t2 = SslHelper.GetServerStream(s2, cert);

            Task.WaitAll(t1, t2);

            s1 = t1.Result;
            s2 = t2.Result;

            Task.WaitAll(StreamTest.RunClient(s1), StreamTest.RunServer(s2));
        }
Exemplo n.º 4
0
        private static async Task <(ClientHandler clientHandler, ServerHandler serverHandler)> StartOneAsync(X509Certificate2 cert, int messageSize)
        {
            // TODO: Use updated ProducerConsumerStream
            (Stream s1, Stream s2) = ProducerConsumerStream.Create();

            // Note, this doesn't handle hangs properly and should be reworked
            if (cert != null)
            {
                var t1 = SslHelper.GetClientStream(s1);
                var t2 = SslHelper.GetServerStream(s2, cert);
                await Task.WhenAll(t1, t2);

                s1 = t1.Result;
                s2 = t2.Result;
            }

            var clientHandler = new ClientHandler(s1, messageSize);
            var serverHandler = new ServerHandler(s2, messageSize);

            return(clientHandler, serverHandler);
        }