title: Python socket receiving multiple packets at once
body: <p>When I connect my Python client to the server, two packets are being sent to the client:</p>
  
  <p>First one is:</p>
  
  <pre><code>FD 01
  </code></pre>
  
  <p>Second one:</p>
  
  <pre><code>FF 66 46 3E 61 37 07 CA 0B
  </code></pre>
  
  <p>However, when I'm trying to receive them in my Python client through sockets, I receive both at once:</p>
  
  <pre><code>FD 01 FF 66 46 3E 61 37 07 CA 0B
  </code></pre>
  
  <p>I want to receive packets into my buffer each after eachother, so I could parse one packet, do some job in the background and parse another packet in queue. How can I solve this?</p>
  
  <p>This is my client code:</p>
  
  <pre><code>class ReceivePacket():
      def __init__(self, bytes):
          reply = str(bytes).encode('hex')
          print "&lt;- [{}] - {}".format(headers.RECV.get(int(reply[:2], 16), int(reply[:2], 16)),
                                      ' '.join([reply[i:i + 2] for i in range(0, len(reply), 2)]).upper())
  
  class Client(threading.Thread):
      def __init__(self):
          threading.Thread.__init__(self)
  
          self.size = 1024
          self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # type: socket.socket
  
          self.buf = bytearray(self.size)
  
          self.net = network.Network()
          self.net.bindClient(self)
  
          try:
              self.sock.connect((HOST, AUTH_PORT))
          except socket.error, msg:
              raise
  
      def run(self):
          while True:
              reply = self.sock.recv_into(memoryview(self.buf))
  
              if reply:
                  self.receive(reply)
  
      def receive(self, nbytes):
          ReceivePacket(self.buf) # Having FD 01 FF 66 46 3E 61 37 07 CA 0B here
  
  c = Client()
  c.start()
  </code></pre>