urllib and binding to a interface on a multihomed system

Peter Hansen peter at engcorp.com
Mon Apr 7 08:58:02 EDT 2003


?????? ?. wrote:
> 
> I have a computer that's connected to three networks.
> On that computer I have a python script that uses urllib or urllib2 to fetch
> urls and POST data...
> 
> The problem is, I want the outgoing IP address of the connections made by
> urllib[2] to be one of the interfaces and not the default selected by the
> kernel. I can do this to low-level sockets with the "bind" method... Can I
> do the same thing to urllib?

Judging by the source code for urllib.py, which calls httplib.py, which 
directly creates and immediately attempts to connect() the socket involved
in its HTTPConnection.connect() method, the answer is No.

-Peter




More information about the Python-list mailing list