--- /dev/null
+#ifndef SCD_CHAN_MAN_H
+#define SCD_CHAN_MAN_H
+
+#include <string>
+#include <list>
+
+#include <systemc>
+using sc_core::sc_prim_channel;
+
+#include "scd_simulator.h"
+#include "scd_command.h"
+#include "scd_chan_wrapper.h"
+#include "scd_out_connector.h"
+
+
+/* forward declaration */
+class scd_out_connector;
+class scd_chan_wrapper;
+
+
+/**
+ * The channel manager holds all remote channels. The channels have
+ * to be registered before the simulator is initiated. The channel
+ * manager will then initiate connections to other simulators
+ * and will handle channels from incomming connections.
+ * During simulation data is sent from the channel output buffers
+ * to remote hosts and data is received and stored in the input buffers.
+ * The channel implementation will then generate events to resume
+ * simulation processes.
+ */
+class scd_chan_man
+{
+public:
+ /**
+ * Constructor.
+ * \param sim the simulator
+ */
+ scd_chan_man(scd_simulator &sim);
+
+ virtual ~scd_chan_man();
+
+ /**
+ * Registers a remote channel with master endpoint on this host.
+ * Another host will initiate the connection and the channel will
+ * be connected by an in-connector calling connect_channel().
+ * \param name the name of the remote channel
+ * \param mchan the SystemC channel implementing the
+ * remote-in and/or the remote-out interface.
+ */
+ void register_channel(const std::string &name, sc_prim_channel& mchan);
+
+ /**
+ * Registers a remote channel with slave endpoint on this host.
+ * This host will initiate the connection to the host with the
+ * master endpoint. To drive this process init_process() has to
+ * be called periodically.
+ * \param name the name of the remote channel
+ * \param mchan the SystemC channel implementing the
+ * remote-in and/or the remote-out interface.
+ * \param host the FQDN or IP address of the remote simulator
+ * with the master endpoint of the channel
+ * \param port TCP port of the remote simulator
+ */
+ void register_channel(const std::string &name, sc_prim_channel& schan,
+ const std::string &host, const uint16_t port);
+ /**
+ * Drives the initialization process. Restarts outgoing connection
+ * attempts to connect channels to other simulators if previous
+ * attempts have timed out. ready() indicates the end of the
+ * initialization.
+ */
+ void init_process();
+
+ /**
+ * Connects a channel from an incomming connection. Is intended to be
+ * called from an in-connector.
+ * \param c the register command received by the in-connector (contains
+ * the channel name)
+ * \param sock the socket of the incoming connection that is used
+ * as the data channel
+ */
+ void connect_channel(const scd_command &c, scd_socket* sock);
+
+ /**
+ * Indicates if all clients have been connected.
+ * \return true if the channel manager completed initialization
+ */
+ bool ready() const;
+
+ /**
+ * Checks if channels have data in the output buffers and activates
+ * the transmission if necessary. Receiption is resumed if the input
+ * buffer can accept data again. Call this function after each
+ * simulation step (which might fill data into the buffers that has
+ * to be sent).
+ */
+ void process();
+
+ /**
+ * Closes all channels.
+ */
+ void close();
+
+private:
+ /* member variables */
+ scd_simulator& _sim;
+ std::list<scd_chan_wrapper*> _channels;
+ std::list<scd_out_connector*> _connectors;
+
+ bool _is_ready;
+
+ /* member functions */
+ bool _check_ready();
+ scd_chan_wrapper* _get_channel(const std::string& name);
+};
+
+#endif