+// vim: set noexpandtab tabstop=4 shiftwidth=4:
+//----------------------------------------------------------------------------
+// PlaQui
+//----------------------------------------------------------------------------
+// This file is part of PlaQui.
+//
+// PlaQui is free software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the Free Software
+// Foundation; either version 2 of the License, or (at your option) any later
+// version.
+//
+// PlaQui is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+// details.
+//
+// You should have received a copy of the GNU General Public License along
+// with PlaQui; if not, write to the Free Software Foundation, Inc., 59 Temple
+// Place, Suite 330, Boston, MA 02111-1307 USA
+//----------------------------------------------------------------------------
+// Creado: Tue Oct 21 23:42:46 ART 2003
+// Autores: Leandro Lucarella <llucare@fi.uba.ar>
+//----------------------------------------------------------------------------
+//
+// $Id$
+//
+
+#ifndef PLAQUI_TCPSERVER_H
+#define PLAQUI_TCPSERVER_H
+
+#include "plaqui/server/controlserver.h"
+#include "plaqui/server/transmitter.h"
+#include <socket++/sockinet.h>
+#include <string>
+#include <list>
+
+namespace PlaQui {
+
+namespace Server {
+
+ /**
+ * Servidor de plantas químicas.
+ * Maneja muchas conexiones, de control o de transmisión.
+ */
+ class TCPServer: public Runnable {
+
+ // Tipos.
+
+ private:
+
+ /// Lista de conexiones de control.
+ typedef std::list<Connnection*> ConnectionList;
+
+ // Atributos.
+
+ private:
+
+ /// Socket para escuchar conexiones.
+ sockinetbuf socket;
+
+ /// Conexiones de control.
+ ConnectionList connections;
+
+ // Métodos.
+
+ private:
+
+ /**
+ * Entra en el loop para atender conexiones.
+ */
+ virtual void real_run(void);
+
+ protected:
+
+ /**
+ * Obtiene una nueva \ref Connection "conexión".
+ *
+ * \param sd Descriptor del socket de la nueva conexión.
+ *
+ * \return Nueva conexión.
+ */
+ virtual Connection* new_connection(const sockbuf::sockdesc& sd) = 0;
+
+ public:
+
+ /**
+ * Destructor.
+ */
+ virtual ~TCPServer(void) {}
+
+ /**
+ * Constructor.
+ *
+ * \param port Puerto en el cual escuchar.
+ */
+ TCPServer(int port);
+
+ /**
+ * Se encarga de borrar una conexión de la lista cuando finaliza.
+ *
+ * \param connection Conexión a eliminar.
+ */
+ void on_connection_finished(Connection* connection);
+
+ };
+
+}
+
+}
+
+#endif // PLAQUI_TCPSERVER_H