On Mon, Aug 05 2013, Lars Magne Ingebrigtsen wrote: > Whether you have a pool of connections or kill/reconnect, the problem > remains the same: Figuring out when to switch connections/reconnect. > > And in the case that the IP address changed, all your connections in the > pool will hang, so it doesn't really help... It would help a lot: - connections would be stuck in the *background*, avoiding getting your Emacs frozen; - connections will eventually time out (the kernel does have a TCP timeout), and you will be able to reschedule the operation since you used a queue. Also, sqending regular NOOP command should triggers early detection of IP changes. If I'm not mistaken, if the kernel thinks you have a TCP session established, but your NATed public IP address changed, the remote server is going to send you a RST or something like that as soon as it received something, and the kernel will consider the connection as no more valid and will close it. That could even work for long operation: - send a COMMAND that takes a lot of time - change your public network IP address - send a NOOP (seems you can do that, check http://tools.ietf.org/html/rfc3501#section-5.5) -> if the remote server doesn't know your public IP address, the connection will be reset; restart! -> if the connection's good, the server might replies now, or later (see RFC) My 2c, -- Julien Danjou ;; Free Software hacker ; freelance consultant ;; http://julien.danjou.info