Index: src/Fragmentation/Automation/FragmentController.cpp
===================================================================
--- src/Fragmentation/Automation/FragmentController.cpp	(revision db03d94db34e97b2e16df2332a1953abdf66be98)
+++ src/Fragmentation/Automation/FragmentController.cpp	(revision 3c4a5ec6700394439a96a697b6964a634d5ec97f)
@@ -93,4 +93,38 @@
 }
 
+/** Handle completion of a connect operation.
+ *
+ * \param e error code if something went wrong
+ * \param endpoint_iterator endpoint of the connection
+ */
+void FragmentController::handle_connect_check(const boost::system::error_code& e,
+    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Start operation to read the vector
+    // of jobs. The connection::async_write() function will automatically
+    // encode the data that is written to the underlying socket.
+    LOG(1, "INFO: Checking number of done jobs ...");
+    connection_.async_read(doneJobs,
+      boost::bind(&FragmentController::handle_ReceiveDoneJobs, this,
+      boost::asio::placeholders::error));
+  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
+    // Try the next endpoint.
+    connection_.socket().close();
+    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+    connection_.socket().async_connect(endpoint,
+      boost::bind(&FragmentController::handle_connect_check, this,
+      boost::asio::placeholders::error, ++endpoint_iterator));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    Exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+}
+
 /** Callback function when jobs have been sent.
  *
@@ -100,6 +134,28 @@
 {
   Info info(__FUNCTION__);
-  // do nothing
-  LOG(1, "INFO: Jobs sent.");
+  if (!e)
+  {
+    LOG(1, "INFO: Sent jobs ...");
+  }
+  else
+  {
+    // An error occurred.
+    Exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+
+  // Since we are not starting a new operation the io_service will run out of
+  // work to do and the client will exit.
+}
+
+/** Callback function when doneJobs have been received.
+ *
+ * \param e error code if something went wrong
+ */
+void FragmentController::handle_ReceiveDoneJobs(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+  // Nothing to do.
+  LOG(1, "INFO: "+toString(doneJobs)+" jobs are currently done.");
 }
 
@@ -137,4 +193,22 @@
 }
 
+/** Internal function to connect to the endpoint of the server asynchronuously.
+ *
+ * We require internal connetion_ and host and service to be set up for this.
+ */
+void FragmentController::connect_check()
+{
+  Info info(__FUNCTION__);
+  // Resolve the host name into an IP address.
+  boost::asio::ip::tcp::resolver::iterator endpoint_iterator = getEndpointIterator();
+  boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+
+  // Start an asynchronous connect operation.
+  std::cout << "Connecting to endpoint " << endpoint << " to check " << std::endl;
+  connection_.socket().async_connect(endpoint,
+    boost::bind(&FragmentController::handle_connect_check, this,
+      boost::asio::placeholders::error, ++endpoint_iterator));
+}
+
 /** Internal function to disconnect connection_ correctly.
  *
@@ -165,2 +239,22 @@
 }
 
+/** Prepares the calculation of the results for the current jobs.
+ */
+void FragmentController::checkResults()
+{
+  Info info(__FUNCTION__);
+  // connect
+  connect_check();
+  //disconnect
+  disconnect();
+}
+
+/** Getter for doneJobs.
+ *
+ * \sa checkResults()
+ * \param doneJobs
+ */
+size_t FragmentController::getDoneJobs() const
+{
+  return doneJobs;
+}
Index: src/Fragmentation/Automation/FragmentController.hpp
===================================================================
--- src/Fragmentation/Automation/FragmentController.hpp	(revision db03d94db34e97b2e16df2332a1953abdf66be98)
+++ src/Fragmentation/Automation/FragmentController.hpp	(revision 3c4a5ec6700394439a96a697b6964a634d5ec97f)
@@ -41,6 +41,13 @@
       boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
 
+  /// Handle completion of a accept operation.
+  void handle_connect_check(const boost::system::error_code& e,
+      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
+
   /// Callback function when bunch of jobs have been sent.
   void handle_SendJobs(const boost::system::error_code& e);
+
+  /// Callback function when doneJobs have been received.
+  void handle_ReceiveDoneJobs(const boost::system::error_code& e);
 
   /// place number of jobs into this controller
@@ -61,4 +68,10 @@
   }
 
+  /// get the number of finished results for the current jobs
+  void checkResults();
+
+  /// Getter for doneJobs
+  size_t getDoneJobs() const;
+
 private:
   /// internal function to resolve host name and ip address
@@ -67,4 +80,7 @@
   /// internal function to connect to server and send jobs for calculating jobs
   void connect_calc();
+
+  /// internal function to connect to server and send jobs for checking donejobs
+  void connect_check();
 
   /// internal function to disconnect from server
@@ -86,4 +102,7 @@
   /// flag to give on program exit
   enum Exitflag_t Exitflag;
+
+  /// currently calculated results
+  size_t doneJobs;
 };
 
Index: src/Fragmentation/Automation/FragmentScheduler.cpp
===================================================================
--- src/Fragmentation/Automation/FragmentScheduler.cpp	(revision db03d94db34e97b2e16df2332a1953abdf66be98)
+++ src/Fragmentation/Automation/FragmentScheduler.cpp	(revision 3c4a5ec6700394439a96a697b6964a634d5ec97f)
@@ -125,4 +125,5 @@
     // accept operation the io_service will run out of work to do and the
     // server will exit.
+    Exitflag = WorkerErrorFlag;
     ELOG(0, e.message());
   }
@@ -184,5 +185,5 @@
   if (!e)
   {
-    if (jobs.empty()) {
+    if (JobsQueue.isJobPresent() || !JobsQueue.getDoneJobs()) {
       // The connection::async_write() function will automatically
       // serialize the data structure for us.
@@ -191,4 +192,13 @@
         boost::bind(&FragmentScheduler::handle_ReceiveJobs, this,
         boost::asio::placeholders::error, conn));
+    } else {
+      // we just give a status report ...
+      // first update number
+      doneJobs = JobsQueue.getDoneJobs();
+      // now we accept connections to check for state of calculations
+      LOG(1, "INFO: Sending state of results to controller ...");
+      conn->async_write(doneJobs,
+        boost::bind(&FragmentScheduler::handle_CheckResultState, this,
+        boost::asio::placeholders::error, conn));
     }
   }
@@ -198,5 +208,5 @@
     // accept operation the io_service will run out of work to do and the
     // server will exit.
-    Exitflag = ErrorFlag;
+    Exitflag = ControllerErrorFlag;
     ELOG(0, e.message());
   }
@@ -230,2 +240,13 @@
 }
 
+/** Controller callback function when checking on state of results.
+ *
+ * \param e error code if something went wrong
+ * \param conn reference with the connection
+ */
+void FragmentScheduler::handle_CheckResultState(const boost::system::error_code& e, connection_ptr conn)
+{
+  Info info(__FUNCTION__);
+  // do nothing
+  LOG(1, "INFO: Sent that " << doneJobs << " jobs are done.");
+}
Index: src/Fragmentation/Automation/FragmentScheduler.hpp
===================================================================
--- src/Fragmentation/Automation/FragmentScheduler.hpp	(revision db03d94db34e97b2e16df2332a1953abdf66be98)
+++ src/Fragmentation/Automation/FragmentScheduler.hpp	(revision 3c4a5ec6700394439a96a697b6964a634d5ec97f)
@@ -34,5 +34,6 @@
   enum Exitflag_t{
     OkFlag = 0,
-    ErrorFlag = 255
+    ControllerErrorFlag = 254,
+    WorkerErrorFlag = 255
   };
 
@@ -63,4 +64,8 @@
 
 private:
+
+  /// Controller callback function when checking on state of results.
+  void handle_CheckResultState(const boost::system::error_code& e, connection_ptr conn);
+
   /// The acceptor object used to accept incoming worker socket connections.
   boost::asio::ip::tcp::acceptor worker_acceptor_;
@@ -75,4 +80,7 @@
   std::vector<FragmentJob> jobs;
 
+  /// number of jobs that are calculated, required for returning status
+  size_t doneJobs;
+
   /// Queue with data to be sent to each client.
   FragmentQueue JobsQueue;
Index: src/Fragmentation/Automation/Makefile.am
===================================================================
--- src/Fragmentation/Automation/Makefile.am	(revision db03d94db34e97b2e16df2332a1953abdf66be98)
+++ src/Fragmentation/Automation/Makefile.am	(revision 3c4a5ec6700394439a96a697b6964a634d5ec97f)
@@ -45,5 +45,5 @@
 AM_CPPFLAGS = ${BOOST_CPPFLAGS} ${CodePatterns_CFLAGS}
 
-bin_PROGRAMS += JobAdder Server Worker
+bin_PROGRAMS += JobAdder ResultChecker Server Worker
 
 CONTROLLERSOURCE = \
@@ -81,4 +81,16 @@
   ${CodePatterns_LIBS}
 
+ResultChecker_SOURCES = $(CONTROLLERSOURCE) $(CONTROLLERHEADER) ResultChecker.cpp
+ResultChecker_LDFLAGS = $(AM_LDFLAGS) $(BOOST_ASIO_LDFLAGS) $(BOOST_SYSTEM_LDFLAGS) $(BOOST_THREAD_LDFLAGS) $(BOOST_SERIALIZATION_LDFLAGS)
+ResultChecker_CXXFLAGS = $(AM_CPPFLAGS)
+ResultChecker_LDADD = \
+  libMolecuilderFragmentJobs.la \
+  libMolecuilderFragmentationAutomation.la \
+  $(BOOST_ASIO_LIBS) \
+  $(BOOST_SERIALIZATION_LIBS) \
+  $(BOOST_THREAD_LIBS) \
+  $(BOOST_SYSTEM_LIBS) \
+  ${CodePatterns_LIBS}
+
 Server_SOURCES = $(SERVERSOURCE) $(SERVERHEADER) Server.cpp
 Server_LDFLAGS = $(AM_LDFLAGS) $(BOOST_ASIO_LDFLAGS) $(BOOST_SYSTEM_LDFLAGS) $(BOOST_THREAD_LDFLAGS) $(BOOST_SERIALIZATION_LDFLAGS)
Index: src/Fragmentation/Automation/ResultChecker.cpp
===================================================================
--- src/Fragmentation/Automation/ResultChecker.cpp	(revision 3c4a5ec6700394439a96a697b6964a634d5ec97f)
+++ src/Fragmentation/Automation/ResultChecker.cpp	(revision 3c4a5ec6700394439a96a697b6964a634d5ec97f)
@@ -0,0 +1,76 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2011 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * \file ResultChecker.cpp
+ *
+ * This file strongly follows the Serialization example from the boost::asio
+ * library (see client.cpp)
+ *
+ *  Created on: Nov 27, 2011
+ *      Author: heber
+ */
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include <iostream>
+#include <vector>
+
+#include "atexit.hpp"
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "FragmentController.hpp"
+#include "FragmentJob.hpp"
+#include "FragmentResult.hpp"
+
+
+int main(int argc, char* argv[])
+{
+  // from this moment on, we need to be sure to deeinitialize in the correct order
+  // this is handled by the cleanup function
+  atexit(cleanUp);
+
+  setVerbosity(3);
+
+  size_t Exitflag = 0;
+  try
+  {
+    // Check command line arguments.
+    if (argc != 3)
+    {
+      std::cerr << "Usage: " << argv[0] << " <host> <port>" << std::endl;
+      return 1;
+    }
+
+    boost::asio::io_service io_service;
+    FragmentController controller(io_service, argv[1], argv[2]);
+
+    controller.checkResults();
+    {
+      Info info("io_service");
+      io_service.run();
+    }
+    size_t doneJobs = controller.getDoneJobs();
+    LOG(1, "INFO: " << doneJobs << " jobs are calculated so far.");
+    Exitflag = controller.getExitflag();
+  }
+  catch (std::exception& e)
+  {
+    std::cerr << e.what() << std::endl;
+  }
+
+  return Exitflag;
+}
