Index: src/Fragmentation/Automation/Controller/CommandRegistry.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/CommandRegistry.cpp	(revision 7dd8bca153017cd0e2b65e43da5fb1c8209e754f)
+++ src/Fragmentation/Automation/Controller/CommandRegistry.cpp	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
@@ -34,3 +34,3 @@
 {}
 
-CONSTRUCT_REGISTRY(AsyncOperation)
+CONSTRUCT_REGISTRY(Operation)
Index: src/Fragmentation/Automation/Controller/CommandRegistry.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/CommandRegistry.hpp	(revision 7dd8bca153017cd0e2b65e43da5fb1c8209e754f)
+++ src/Fragmentation/Automation/Controller/CommandRegistry.hpp	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
@@ -14,8 +14,8 @@
 #endif
 
-#include "Controller/Commands/AsyncOperation.hpp"
+#include "Controller/Commands/Operation.hpp"
 #include "CodePatterns/Registry.hpp"
 
-class CommandRegistry : public Registry<AsyncOperation>
+class CommandRegistry : public Registry<Operation>
 {
 public:
Index: src/Fragmentation/Automation/Controller/Commands/AsyncOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/AsyncOperation.cpp	(revision 7dd8bca153017cd0e2b65e43da5fb1c8209e754f)
+++ src/Fragmentation/Automation/Controller/Commands/AsyncOperation.cpp	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
@@ -31,22 +31,4 @@
 
 #include "Controller/Commands/AsyncOperation.hpp"
-
-
-/** Constructor for class AsyncOperation.
- *
- * \param _name name for this Operation for retrieval from a registry
- * \param _connection connection to operate on
- */
-AsyncOperation::AsyncOperation(const std::string &_name, Connection &_connection) :
-    connection_(_connection),
-    name(_name),
-    Exitflag(OkFlag)
-{}
-
-/** Destructor for class AsyncOperation.
- *
- */
-AsyncOperation::~AsyncOperation()
-{}
 
 /** Callback function when an operation has been completed.
@@ -97,2 +79,3 @@
       boost::asio::placeholders::error, ++endpoint_iterator));
 }
+
Index: src/Fragmentation/Automation/Controller/Commands/AsyncOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/AsyncOperation.hpp	(revision 7dd8bca153017cd0e2b65e43da5fb1c8209e754f)
+++ src/Fragmentation/Automation/Controller/Commands/AsyncOperation.hpp	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
@@ -18,17 +18,28 @@
 #include <vector>
 
-#include "Connection.hpp"
+#include "Operation.hpp"
 
-class AsyncOperation {
+class AsyncOperation : public Operation {
 public:
-  AsyncOperation(const std::string &_name, Connection &_connection);
-  virtual ~AsyncOperation();
+  /** Constructor for class AsyncOperation.
+   *
+   * \param _name name for this AsyncOperation for retrieval from a registry
+   * \param _connection connection to operate on
+   */
+  AsyncOperation(const std::string &_name, Connection &_connection) :
+    Operation(_name, _connection)
+  {}
+
+  /** Destructor for class AsyncOperation.
+   *
+   */
+  virtual ~AsyncOperation()
+  {}
+
 public:
-  /// The Connection to the server.
-  Connection &connection_;
-
   // virtual function pointer to the operation to do
   void operator()(const std::string& _host, const std::string& _service);
 
+protected:
   // virtual function pointer to the connection handler
   virtual void handle_connect(const boost::system::error_code& e,
@@ -38,32 +49,7 @@
   void handle_FinishOperation(const boost::system::error_code& e);
 
-  enum Exitflag_t {
-    OkFlag = 0,
-    ErrorFlag = 255
-  };
-
-  /** Getter for Exitflag.
-   *
-   * @return Exitflag
-   */
-  size_t getExitflag() const
-  {
-    return Exitflag;
-  }
-
-  std::string getName() const {
-    return name;
-  }
-
-private:
-  /// Name of this Operation (required for Registry pattern)
-  std::string name;
-
 protected:
   /// internal function to disconnect from server
   void disconnect();
-
-  // exit flag of this operation
-  enum Exitflag_t Exitflag;
 };
 
Index: src/Fragmentation/Automation/Controller/Commands/Operation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/Operation.hpp	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
+++ src/Fragmentation/Automation/Controller/Commands/Operation.hpp	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
@@ -0,0 +1,85 @@
+/*
+ * Operation.hpp
+ *
+ *  Created on: Mar 04, 2012
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_OPERATION_HPP_
+#define FRAGMENTCONTROLLER_OPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string>
+
+#include "Connection.hpp"
+
+
+/** Class Operation defines the general interface common all Operations
+ * whether synchronous or asynchronous. This allows for their storage in
+ * a registry.
+ *
+ */
+class Operation
+{
+public:
+  /** Constructor for class Operation.
+   *
+   * @param _connection connection to use for connect and disconnect
+   * @param _name internal name to allow storage in a registry
+   */
+  Operation(const std::string &_name, Connection &_connection) :
+    connection_(_connection),
+    Exitflag(OkFlag),
+    name(_name)
+  {}
+  virtual ~Operation()
+  {}
+
+  /** Central virtual function that each class deriving from Operation has to implement.
+   *
+   * Here, connect, some read/writes, and disconnect should occur.
+   *
+   * @param _host host address to connect to
+   * @param _service service to connect to
+   */
+  virtual void operator()(const std::string& _host, const std::string& _service) = 0;
+
+  enum Exitflag_t {
+    OkFlag = 0,
+    ErrorFlag = 255
+  };
+
+  /** Getter for Exitflag.
+   *
+   * @return Exitflag
+   */
+  size_t getExitflag() const
+  {
+    return Exitflag;
+  }
+
+  /** Getter for name.
+   *
+   * @return const reference to Operation::name.
+   */
+  const std::string &getName() const {
+    return name;
+  }
+
+protected:
+  /// The Connection to the server.
+  Connection &connection_;
+
+  // exit flag of this operation, derived classes may change it
+  enum Exitflag_t Exitflag;
+
+private:
+  /// Name of this AsyncOperation (required for Registry pattern)
+  std::string name;
+};
+
+#endif /* FRAGMENTCONTROLLER_OPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.cpp	(revision 7dd8bca153017cd0e2b65e43da5fb1c8209e754f)
+++ src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.cpp	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
@@ -27,38 +27,16 @@
 #include "Connection.hpp" // Must come before boost/serialization headers.
 #include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
 #include "ControllerChoices.hpp"
 
 #include "Controller/Commands/ShutdownOperation.hpp"
 
-/** Handle connect operation to shutdown scheduler.
+/** Virtual internal function to give shutdown choice.
  *
- * \param e error code if something went wrong
- * \param endpoint_iterator endpoint of the connection
  */
-void ShutdownOperation::handle_connect(const boost::system::error_code& e,
-    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
+void ShutdownOperation::internal()
 {
   Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Give choice.
-    enum ControllerChoices choice = ShutdownControllerSocket;
-    connection_.async_write(choice,
-      boost::bind(&ShutdownOperation::handle_FinishOperation, 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(&ShutdownOperation::handle_connect, 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());
-  }
+  enum ControllerChoices choice = ShutdownControllerSocket;
+  connection_.sync_write(choice);
 }
+
Index: src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.hpp	(revision 7dd8bca153017cd0e2b65e43da5fb1c8209e754f)
+++ src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.hpp	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
@@ -20,18 +20,20 @@
 #include "Connection.hpp"
 
-#include "Controller/Commands/AsyncOperation.hpp"
+#include "Controller/Commands/SyncOperation.hpp"
 
-class ShutdownOperation : public AsyncOperation  {
+/** Synchronous operation that gives shutdown command.
+ *
+ */
+class ShutdownOperation : public SyncOperation  {
 public:
   /// Constructor for class ShutdownOperation.
   ShutdownOperation(Connection &_connection) :
-    AsyncOperation(std::string("shutdown"),_connection) {}
+    SyncOperation(std::string("shutdown"),_connection) {}
   /// Destructor for class ShutdownOperation
   ~ShutdownOperation() {}
 
 public:
-  // virtual function pointer to the connection handler
-  virtual void handle_connect(const boost::system::error_code& e,
-      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
+  // function that implements read&writes in between connect/disconnect
+  virtual void internal();
 };
 
Index: src/Fragmentation/Automation/Controller/Commands/SyncOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SyncOperation.cpp	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
+++ src/Fragmentation/Automation/Controller/Commands/SyncOperation.cpp	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
@@ -0,0 +1,79 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * SyncOperation.cpp
+ *
+ *  Created on: Mar 04, 2012
+ *      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 <boost/bind.hpp>
+#include <vector>
+#include "Connection.hpp" // Must come before boost/serialization headers.
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+
+#include "Controller/Commands/SyncOperation.hpp"
+
+/** Internal function to connect connection_.
+ *
+ */
+void SyncOperation::connect(const std::string& _host, const std::string& _service)
+{
+  // Resolve the host name into an IP address.
+  boost::asio::ip::tcp::resolver resolver(connection_.socket().get_io_service());
+  boost::asio::ip::tcp::resolver::query query(_host, _service);
+  boost::asio::ip::tcp::resolver::iterator endpoint_iterator =
+    resolver.resolve(query);
+  boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+
+  // Start an asynchronous connect operation.
+  std::cout << "Connecting to endpoint " << endpoint << " ..." << std::endl;
+  connection_.socket().connect(endpoint);
+}
+
+
+/** Internal function to disconnect connection_ correctly.
+ *
+ */
+void SyncOperation::disconnect()
+{
+  connection_.socket().close();
+}
+
+/** Wrapper function for the virtual call to internal() that connects and disconnects.
+ *
+ * @param _host host address to connect to
+ * @param _service service to connect to
+ */
+void SyncOperation::operator()(const std::string& _host, const std::string& _service)
+{
+  LOG(1, "INFO: Commencing operation ...");
+
+  // connect
+  connect(_host, _service);
+
+  // call virtual function to continue
+  internal();
+
+  // disconnect
+  disconnect();
+
+  LOG(1, "INFO: Operation completed.");
+}
Index: src/Fragmentation/Automation/Controller/Commands/SyncOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SyncOperation.hpp	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
+++ src/Fragmentation/Automation/Controller/Commands/SyncOperation.hpp	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
@@ -0,0 +1,54 @@
+/*
+ * SyncOperation.hpp
+ *
+ *  Created on: Mar 04, 2012
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_SYNCOPERATION_HPP_
+#define FRAGMENTCONTROLLER_SYNCOPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+
+#include "Operation.hpp"
+
+class SyncOperation : public Operation {
+public:
+  /** Constructor for class SyncOperation.
+   *
+   * \param _name name for this Operation for retrieval from a registry
+   * \param _connection connection to operate on
+   */
+  SyncOperation(const std::string &_name, Connection &_connection) :
+    Operation(_name, _connection)
+  {}
+
+  /** Destructor for class SyncOperation.
+   *
+   */
+  virtual ~SyncOperation()
+  {}
+
+public:
+  // virtual function pointer to the operation to do
+  void operator()(const std::string& _host, const std::string& _service);
+
+protected:
+  // function that implements read&writes in between connect/disconnect
+  virtual void internal() = 0;
+
+  // internal function to connect to server
+  void connect(const std::string& _host, const std::string& _service);
+
+  /// internal function to disconnect from server
+  void disconnect();
+};
+
+#endif /* FRAGMENTCONTROLLER_SYNCOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Makefile.am
===================================================================
--- src/Fragmentation/Automation/Makefile.am	(revision 7dd8bca153017cd0e2b65e43da5fb1c8209e754f)
+++ src/Fragmentation/Automation/Makefile.am	(revision 701bbc41bd25695e7b3b73c64db57c48c3771e36)
@@ -52,5 +52,6 @@
   Controller/Commands/SendResultsOperation.cpp \
   Controller/Commands/ShutdownOperation.cpp \
-  Controller/Commands/SubmitResultOperation.cpp
+  Controller/Commands/SubmitResultOperation.cpp \
+  Controller/Commands/SyncOperation.cpp
 
 FRAGMENTATIONCOMMANDSHEADER = \
@@ -61,9 +62,11 @@
   Controller/Commands/GetNextJobIdOperation.hpp \
   Controller/Commands/ObtainJobOperation.hpp \
+  Controller/Commands/Operation.hpp \
   Controller/Commands/ReceiveJobsOperation.hpp \
   Controller/Commands/SendJobToWorkerOperation.hpp \
   Controller/Commands/SendResultsOperation.hpp \
   Controller/Commands/ShutdownOperation.hpp \
-  Controller/Commands/SubmitResultOperation.hpp
+  Controller/Commands/SubmitResultOperation.hpp \
+  Controller/Commands/SyncOperation.hpp
 
 noinst_LTLIBRARIES += libMolecuilderFragmentationCommands.la
