Hello I’m trying to use protected http socks server with socket module as in the code shown below
>>> import socket
>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> host = 'http://user:pass@server.com'
>>> port = 8888
>>> s.bind((host, port))
It gives me error:
socket.gaierror: [Errno -2] Name or service not known
Though if I setup proxy on a Firefox it works fine. What is in the code?
Sultan
I believe your problem is because your host is malformed. The Socket host is just a name not a protocol. Your host should be something like:
The authentication should be done after you connect, i.e., the first message you send is the authentication.
I can’t give you the specifics of how to authenticate because that greatly depends on the server you are connecting to. Check this question