title: TCP / Async Receive Handle for more then 500 clients
body: <p>I am a complete beginner in the TCP section, I try to program a Master Server which should handle more then 500 clients with small delay.</p>
  
  <p>This is my first attempt, do you have any suggestions how to improve the code, or is my code complete garbage! :D</p>
  
  <p>I send a Uint16 first as indicator of the message size</p>
  
  <pre><code>    // receive Code!
      private byte[] indexBuffer = new byte[sizeof(UInt16)];
      private int indexSize = sizeof(UInt16);
  
      public async void receiveData(TcpClient client) {
         var result = await Task.Run(() =&gt; {
             try {
                 int checkSum = client.Client.Receive(indexBuffer, 0, indexBuffer.Length, SocketFlags.None);
                 if (checkSum != indexSize) return null;
  
                 int packageSize = BitConverter.ToUInt16(indexBuffer, 0);
                 Console.WriteLine(packageSize);
                 var recData = new Byte[packageSize];
  
                 checkSum = client.Client.Receive(recData, 0, packageSize, SocketFlags.None);
                 if (checkSum != packageSize) return null;
                 return Encoding.ASCII.GetString(recData);
             } catch(Exception ex) {
                 Console.WriteLine(ex.Message);
                 return "-1";
             }
          });
  
          // blabla do something 
          Console.WriteLine(result);
  
          //---------------------
          if (client.Connected) 
             receiveData(client);
      }
  </code></pre>