Choosing Source Address to Bind Socket to in IMAP Client

Prasad, Ramit ramit.prasad at jpmorgan.com
Tue Nov 20 17:41:13 EST 2012


brintoul at controlledthinking.com wrote:
> > > I have a multihomed machine that I would like to run the Python imaplib's IMAP4 client on.  I would like to be
> > > able to specify which interface the underlying socket will bind to as its source address.  How could I best do
> > > this?
[snip]

> While I appreciate your attempt at humor, this is not information which helps me.  Perhaps you are not familiar
> with the basics of socket programming. This is all fine and dandy, and it is good to "know what you don't know".
> If you're interested, look at the third argument to "create_connection":
> http://docs.python.org/2/library/socket.html

Apologies, I misread your question. 

According to the imaplib docs, you can subclass IMAP4 and override 
`IMAP4.open` to create the socket and bind it to the desired interface.
You could also connect using IMAP4 and then close/reopen the socket
inside the IMAP4 connection object. 


I hope that is more help,
Ramit


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  



More information about the Python-list mailing list