2

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

sultan
  • 5,978
  • 14
  • 59
  • 103
  • 1
    I'm not familiar with `protected http socks server`, I think you mean either an authenticated HTTP Proxy or a SOCKS Proxy. The two different protocols can't easily be run on the same port. Which is it? – MattH Sep 01 '10 at 11:33

1 Answers1

1

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:

host = 'server.com'

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

Community
  • 1
  • 1
pedromcaraujo
  • 307
  • 1
  • 4