[Tutor] proxy requiring authentication

Adrian Maier am@fx.ro
Fri Apr 11 09:42:08 2003


Christopher Smith (csmith@blakeschool.org) a scris :
> Can this be translated into Python?  I don't know much about working with
> sockets but read the docs and attempted the following without success (I
> only show the first few lines because the connection could not even be
> established):
> 
> ###
> import socket
> theproxyserver='the.proxy.server' #but I used our proxy name
> theproxyport=42 #but I used the real port number
> s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
> s.bind((theproxyserver, theproxyport)) #fails with error (49, can't assign
> address)
> ###

I guess you should use s.connect instead of s.bind .
'bind' is used when you intend to listen on that port
(which happens inside programs that act like servers). 


You probably got that error because your program is trying
to 'bind' a port that is lower than 1024. On Unix, only
root may listen on those ports.  But, you don't need to
listen on any port ... you need to connect as a
client to the proxy (using s.connect).

I hope this helps.

-- 
Adrian Maier
(am@fx.ro)