title: check the byte length before sending back to severs in socket programming in python
body: <p>My client sends a message to server. The server collects the message <code>16 byte</code>s each time and when it receives anything less than <code>16 bytes</code>, it returns the message (after concatenation) back to the client.</p>
  
  <p>Here is the code from <code>server.py:</code></p>
  
  <pre><code>    sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM,socket.IPPROTO_IP)
      sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
  
      sock.bind(address)
      sock.listen(1)
  
      try:
          while True:
              conn,add=sock.accept()
              addr=(conn,add)
              print add
              try:
                  data = ''
                  while True:
  
                      recvdata=conn.recv(16)
                      print recvdata
                      data+=recvdata
                      if len(recvdata)&lt;16:
                          print &gt;&gt;log_buffer,"sending data"
                          conn.sendall(data)
                          break
  
  
              finally:
                  conn.close()
  
  
      except KeyboardInterrupt:
          sock.close()
  </code></pre>
  
  <p>The code works well for messages above 16 and less than <code>16 byte</code> length, when it is exactly 16 or mutliples of 16, it is not sending back to client. how do I fix for this?
  `</p>