Ejemplo n.º 1
0
 protected override Task RunInternal()
 {
     return(Task.Run(async() =>
     {
         SocketSettings settings = new SocketSettings
         {
             CatchApplicationExceptions = false,
             RsaXmlKey = Library.PublicKey
         };
         LocalClient local = new LocalClient();
         VSLClient client = new VSLClient(settings, local);
         await client.ConnectAsync("::1", Library.Port);
         running = true;
         stopwatch.Start();
         async Task inner()
         {
             while (running && Done < Total)
             {
                 byte[] buf = new byte[random.Next(2048)];
                 random.NextBytes(buf);
                 if (await client.SendPacketAsync(0, buf))
                 {
                     Interlocked.Increment(ref Done);
                 }
                 else
                 {
                     running = false;
                 }
             }
         }
         await Task.WhenAll(Enumerable.Range(0, 4).Select(x => inner()));
     }));
 }
Ejemplo n.º 2
0
        private void BtnSendPacket_Click(object sender, EventArgs e)
        {
            Random rnd = new Random();

            byte[] b = new byte[65536];
            rnd.NextBytes(b);
            if ((Button)sender == btnClientSendPacket)
            {
                vslClient.SendPacketAsync(1, b);
            }
            else if ((Button)sender == btnServerSendPacket)
            {
                Library.Clients.ForEach(c => c.SendPacket(1, b));
            }
        }