[Python] PySocks .listen()

Discussão em 'Python' iniciado por Stack, Junho 6, 2025.

  1. Stack

    Stack Membro Participativo

    I've come across the PySocks library as a tool aimed more at proxies in comparison to the regular Python Sockets module, I was using that but needed to find something else.

    Anyways, with PySocks I saw that it's basically built on top of the Sockets module and if so why can't I use the normal Sockets commands such as .listen and .accept

    Here's a small extract of the code right now (which I've modified from when I was using the Sockets Module) and the error I'm receiving.

    I'm not sure how to fix this, as it states the argument is invalid, so I'm wondering now if this is not a suitable replacement for the sockets module as I do need the listening and accepting capability.

    Code:

    import ssl
    import socks

    socksServer = socks.socksocket()

    def startProxy():
    socksServer.set_proxy(socks.HTTP, "localhost", 8181)
    socksServer.listen(5)
    while True:
    client_socket, clientAddress = socksServer.accept()
    print(f"Connection from {clientAddress} has been accepted")


    Error:

    start_Proxy
    socksServer.listen(5)
    ~~~~~~~~~~~~~~~~~~^^^
    OSError: [WinError 10022] An invalid argument was supplied
    Proxy Server has bound to localhost and port 8181

    Process finished with exit code 1


    Thank you very much for your help

    Continue reading...

Compartilhe esta Página