def _read_exactly(sock, amt):
 data = ''
 while (amt > 0):
  chunk = sock.recv(amt)
  data += chunk
  amt -= len(chunk)
 return data

def _read_exactly ( sock , amt ) : data = '' while ( amt > 0 ) : chunk = sock . recv ( amt ) data += chunk amt -= len ( chunk ) return data
read *exactly* amt bytes from the socket sock .