title: Reading incoming data from socket?
body: <p>I have a Socket Client and I was wondering what would be the correct approach to read the incoming data from it.</p>
  
  <p>Currently I am using the follow function:</p>
  
  <pre><code>private void _ReadResponsePackets()
  {
      while (_socket.Connected)
      {
          try
          {
              byte[] bytes = new byte[1500];
              _socket.Receive(bytes);
              if (bytes.Length &gt; 0)
              LoginserverPackets.Enqueue(bytes);
          }
          catch (Exception ex)
          {
              _log.Write(ErrorType.ERROR, "[LOGINCLIENT] " + ex.ToString(), true);
          }
      }
  }
  </code></pre>
  
  <p>That is called by it is own thread:</p>
  
  <pre><code>Thread _readDataThread = new Thread(_ReadResponsePackets);
  _readDataThread.Start();
  </code></pre>
  
  <p>As you can see I am merelly reading and pilling up the packets received on a queue list to be further threaded but my question here is:</p>
  
  <ul>
  <li>Should I use a Thread.Sleep in my
  read function or leave it as it is ?</li>
  <li>Would it impact more on the
  performance or memory usage as it is
  or using Thread.Sleep ?</li>
  </ul>
  
  <p>Any other toughts ?</p>