def recvall(sock, size: int):
    """Receive data of a specific size from socket.

    If 'size' number of bytes are not received, None is returned.
    """
    buf = b""
    while size:
        newbuf = sock.recv(size)
        if not newbuf:
            return None
        buf += newbuf
        size -= len(newbuf)
    return buf