Python socket.create() raises an errno 10061
Question: When the client tries to connect to the server it always raise an exception. I
have disabled Windows firewall and my antivirus and I have also opened the
port 50100 on the router configuration panel.

Server:

    
    
    import socket
    
    HOST = ''
    PORT = 8882
    
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    
    s.bind((HOST, PORT))
    
    s.listen(1)
    
    conn, addr = s.accept()
    
    s.close()
    

Client:

    
    
    import socket
    
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    
    host = 'localhost'
    port = 50100
    
    remote_ip = s.gethostbyname(host)
    
    s.connect((remote_ip, port))
    
    s.close()
    


Answer: Specify the correct _remote_ port in the client (i.e., the same port as the in
the server script).

    
    
    # Client
    import socket
    
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    
    host = 'localhost'
    port = 8882
    
    remote_ip = socket.gethostbyname(host)
    
    s.connect((remote_ip, port))
    
    s.close()
    

