From 702a6ffb33a4f3ba9109347ae46d943383fbbf64 Mon Sep 17 00:00:00 2001 From: Florian Stecker Date: Mon, 23 Jan 2023 15:46:36 -0500 Subject: [PATCH] reconnect if server closes connection --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3feced1..aa0801c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -269,9 +269,9 @@ pub fn connect_and_idle(cli: &Cli, connected_callback: F, mail } } } else { - break; + // if wants_read() and wants_write() are both false, this usually means the connection was closed + // so just return "Interrupted" and reconnect after a few seconds + return Err(io::Error::new(ErrorKind::Interrupted, "Connection was closed by server").into()); } } - - Ok(()) }