Index: /trunk/FACT++/src/Connection.cc
===================================================================
--- /trunk/FACT++/src/Connection.cc	(revision 11259)
+++ /trunk/FACT++/src/Connection.cc	(revision 11260)
@@ -71,5 +71,5 @@
     // AsyncConnect + Deadline
      async_connect(endpoint,
-                  boost::bind(&Connection::ConnectIterImp,
+                  boost::bind(&Connection::ConnectIter,
                               this, iterator, ba::placeholders::error));
 
@@ -82,5 +82,5 @@
     // AsyncConnect + Deadline
      async_connect(fEndpoint,
-                  boost::bind(&Connection::ConnectAddrImp,
+                  boost::bind(&Connection::ConnectAddr,
                               this, fEndpoint, ba::placeholders::error));
 
@@ -290,5 +290,5 @@
 }
 
-void Connection::ConnectAddrImp(const tcp::endpoint &endpoint, const bs::error_code& error)
+bool Connection::ConnectImp(const tcp::endpoint &endpoint, const bs::error_code& error)
 {
     const string host = endpoint.port()==0 ? "" :
@@ -311,5 +311,5 @@
 
         ConnectionEstablished();
-        return;
+        return true;
     }
 
@@ -334,7 +334,9 @@
 
     if (error==ba::error::basic_errors::operation_aborted)
-        return;
+        return true;
 
     fConnectionStatus = kConnecting;
+
+    return false;
 /*
     // Go on with the next
@@ -352,59 +354,12 @@
 
     // FIXME: Should we move this before AsyncConnect() ?
-    AsyncWait(fConnectionTimer, 250, &Connection::HandleConnectionTimer);
-}
-
-void Connection::ConnectIterImp(tcp::resolver::iterator iterator, const bs::error_code& error)
-{
-    ConnectAddrImp(*iterator, error);
-/*
-    tcp::endpoint endpoint = *iterator;
-
-    const string host = endpoint.port()==0 ? "" :
-        endpoint.address().to_string()+":"+lexical_cast<string>(endpoint.port());
-
-    // Connection established
-    if (!error)
-    {
-	set_option(socket_base::keep_alive(true));
-
-	const int optval = 10;
-        // First keep alive after 10s
-	setsockopt(native(), SOL_TCP, TCP_KEEPIDLE, &optval, sizeof(optval));
-        // New keep alive after 10s
-	setsockopt(native(), SOL_TCP, TCP_KEEPINTVL, &optval, sizeof(optval));
-
-	Info("Connection established to "+host+"...");
-
-        fConnectionStatus = kConnected;
-
-        ConnectionEstablished();
-        return;
-    }
-
-    // If returning from run will lead to deletion of this
-    // instance, close() is not needed (maybe implicitly called).
-    // If run is called again, close() is needed here. Otherwise:
-    // Software caused connection abort when we try to resolve
-    // the endpoint again.
-    CloseImp(false);
-
-    ostringstream msg;
-    if (!host.empty())
-        msg << "Connecting to " << host << ": " << error.message() << " (" << error << ")";
-
-    if (fErrConnect!=msg.str())
-    {
-        if (error!=ba::error::basic_errors::connection_refused)
-            fMsgConnect = "";
-        fErrConnect = msg.str();
-        Warn(fErrConnect);
-    }
-
-    if (error==ba::error::basic_errors::operation_aborted)
-        return;
-
-    fConnectionStatus = kConnecting;
-*/
+//    AsyncWait(fConnectionTimer, 250, &Connection::HandleConnectionTimer);
+}
+
+void Connection::ConnectIter(tcp::resolver::iterator iterator, const bs::error_code& error)
+{
+    if (ConnectImp(*iterator, error))
+        return;
+
     // Go on with the next
     if (++iterator != tcp::resolver::iterator())
@@ -413,14 +368,16 @@
         return;
     }
-/*
+
     // No more entries to try, if we would not put anything else
     // into the queue anymore it would now return (run() would return)
-
-    // Since we don't want to block the main loop, we wait using an
-    // asnychronous timer
-
-    // FIXME: Should we move this before AsyncConnect() ?
     AsyncWait(fConnectionTimer, 250, &Connection::HandleConnectionTimer);
-*/
+}
+
+void Connection::ConnectAddr(const tcp::endpoint &endpoint, const bs::error_code& error)
+{
+    if (ConnectImp(endpoint, error))
+        return;
+
+    AsyncWait(fConnectionTimer, 250, &Connection::HandleConnectionTimer);
 }
 
Index: /trunk/FACT++/src/Connection.h
===================================================================
--- /trunk/FACT++/src/Connection.h	(revision 11259)
+++ /trunk/FACT++/src/Connection.h	(revision 11260)
@@ -82,8 +82,10 @@
     void CloseImp(bool restart=true);
 
-    void ConnectAddrImp(const boost::asio::ip::tcp::endpoint &endpoint,
-                        const boost::system::error_code& error);
-    void ConnectIterImp(boost::asio::ip::tcp::resolver::iterator endpoint_iterator,
-                        const boost::system::error_code& error);
+    bool ConnectImp(const boost::asio::ip::tcp::endpoint &endpoint,
+                    const boost::system::error_code& error);
+    void ConnectIter(boost::asio::ip::tcp::resolver::iterator endpoint_iterator,
+                     const boost::system::error_code& error);
+    void ConnectAddr(const boost::asio::ip::tcp::endpoint &endpoint,
+                     const boost::system::error_code& error);
 
     void HandleConnectionTimer(const boost::system::error_code &error);
