libt2n: (tomj) make compilable again
[libt2n] / src / socket_client.cpp
index 100ca54..4f4975f 100644 (file)
@@ -123,7 +123,7 @@ void socket_client_connection::unix_connect(int max_retries)
     {
         // recurse if retries left
         if (max_retries > 0)
-            tcp_connect(max_retries-1);
+            unix_connect(max_retries-1);
     }
 
     do_callbacks(new_connection);
@@ -185,4 +185,21 @@ void socket_client_connection::close()
     }
 }
 
+/** @brief try to reconnect the current connection with the same connection credentials (host and port or path)
+*/
+void socket_client_connection::reconnect()
+{
+    // close the current connection if still open
+    close();
+
+    socket_type_value type=get_type();
+
+    if (type == tcp_s)
+        tcp_connect(max_retries);
+    else if (type == unix_s)
+        unix_connect(max_retries);
+
+    reopen();
+}
+
 }