Recieve data until msglen bytes have been received.

def recv_blocking(conn, msglen):
    """Recieve data until msglen bytes have been received."""
    msg = b''
    while len(msg) < msglen:
        maxlen = msglen-len(msg)
        if maxlen > 4096:
            maxlen = 4096
        tmpmsg = conn.recv(maxlen)
        if not tmpmsg:
            raise RuntimeError("socket connection broken")
        msg += tmpmsg
        logging.debug("Msglen: %d of %d", len(msg), msglen)
    logging.debug("Message: %s", msg)
    return msg