Exemplo n.º 1
0
 private static async Task StartServer(NetSocketFactory factory, EndPoint endPoint)
 {
     var server = factory.Listen(endPoint);
     while (true)
     {
         var client = await server.Accept();
         StartClientTask(client);
     }
 }
Exemplo n.º 2
0
        private static async Task StartServer(NetSocketFactory factory, EndPoint endPoint)
        {
            var server = factory.Listen(endPoint);

            while (true)
            {
                var client = await server.Accept();

                StartClientTask(client);
            }
        }
Exemplo n.º 3
0
 private static async Task StartClient(NetSocketFactory factory, EndPoint endPoint)
 {
     using (var client = await factory.Connect(endPoint))
     {
         var producer = client.Stream.AsIntLengthPrefixedProducer();
         for (var i = 0; i < 100; i++)
         {
             await producer.Add(GenerateBuffer(i));
         }
         await client.Disconnect();
     }
 }
Exemplo n.º 4
0
 private static async Task StartClient(NetSocketFactory factory, EndPoint endPoint)
 {
     using (var client = await factory.Connect(endPoint))
     {
         var producer = client.Stream.AsIntLengthPrefixedProducer();
         for (var i = 0; i < 100; i++)
         {
             await producer.Add(new ArraySegment<byte>(GenerateBuffer(i)));
         }
         await client.Disconnect();
     }
 }
Exemplo n.º 5
0
        public static async void Work()
        {
            var factory = new NetSocketFactory();

            var endPoint = new IPEndPoint(IPAddress.Loopback, 3232);
            var tasks    = new List <Task>
            {
                StartServer(factory, endPoint),
                StartClient(factory, endPoint),
                StartClient(factory, endPoint),
                StartClient(factory, endPoint),
            };

            await Task.WhenAll(tasks);
        }
Exemplo n.º 6
0
        private static async void Work()
        {
            var factory = new NetSocketFactory();

            var endPoint = new IPEndPoint(IPAddress.Loopback, 3232);
            var tasks = new List<Task>
            {
                StartServer(factory, endPoint),
                StartClient(factory, endPoint),
                StartClient(factory, endPoint),
                StartClient(factory, endPoint),
            };

            await Task.WhenAll(tasks);
        }