Exemple #1
0
        public async Task ReceiveRawMessageNotConnectedSocketShouldReturnNull()
        {
            var peer = new SocketCommunicationManager();

            Assert.IsNull(peer.ReceiveRawMessage());
            Assert.IsNull(await peer.ReceiveRawMessageAsync(CancellationToken.None));
        }
Exemple #2
0
        public void SocketPollShouldNotHangServerClientCommunication()
        {
            // Measure the throughput with socket communication v1 (SocketCommunicationManager)
            // implementation.
            var server = new SocketCommunicationManager();
            var client = new SocketCommunicationManager();

            int port = server.HostServer(new IPEndPoint(IPAddress.Loopback, 0)).Port;

            client.SetupClientAsync(new IPEndPoint(IPAddress.Loopback, port)).Wait();
            server.AcceptClientAsync().Wait();

            server.WaitForClientConnection(1000);
            client.WaitForServerConnection(1000);

            var clientThread = new Thread(() => SendData(client));

            clientThread.Start();

            var dataReceived = 0;

            while (dataReceived < 2048 * 5)
            {
                dataReceived += server.ReceiveRawMessageAsync(CancellationToken.None).Result.Length;
                Task.Delay(1000).Wait();
            }

            clientThread.Join();

            Assert.IsTrue(true);
        }