Specifying an IP address for outbound connections?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • erikcw

    Specifying an IP address for outbound connections?

    Python seems to default to the main system IP for outbound connections
    (such as urllib), but I want to bind to one of my other IPs for
    outbound connections.

    Any ideas?

    Thanks!
  • =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

    #2
    Re: Specifying an IP address for outbound connections?

    erikcw wrote:
    Python seems to default to the main system IP for outbound connections
    (such as urllib), but I want to bind to one of my other IPs for
    outbound connections.
    >
    Any ideas?
    Just use the .bind method of a socket to bind it to a specific address.
    If you then want to continue to use urllib, you'll have to override a
    lot of classes, or monkey-patch, or use, e.g., PyContext to selectively
    replace httplib.HTTPCon nection.connect .

    Regards,
    Martin

    Comment

    Working...