+bool SMUX::Reconnect()
+{
+if (needReconnect && difftime(time(NULL), lastReconnectTry) < reconnectTimeout)
+ return true;
+
+time(&lastReconnectTry);
+SendClosePDU(sock);
+close(sock);
+if (!PrepareNet())
+ if (SendOpenPDU(sock))
+ if (SendRReqPDU(sock))
+ {
+ reconnectTimeout = 1;
+ needReconnect = false;
+ logger("Connected successfully");
+ printfd(__FILE__, "Connected successfully\n");
+ return false;
+ }
+
+if (needReconnect)
+ if (reconnectTimeout < 60)
+ reconnectTimeout *= 2;
+
+needReconnect = true;
+return true;
+}
+