(sock, n)
return data
Receive socket data and detect if the connection was closed.
Receive socket data and detect if the connection was closed.
Receive socket data and detect if the connection was closed .
def recvall(sock, n):
    """Receive socket data and detect if the connection was closed."""
    data = ''
    while len(data) < n:
        packet = sock.recv(n - len(data))
        if not packet:
            return None
        data += packet
    return data
def recvall ( sock , n ) : data = '' while len ( data ) < n : packet = sock . recv ( n - len ( data ) ) if not packet : return None data += packet return data