00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _SERVIDOR_HPP
00030 #define _SERVIDOR_HPP
00031
00032
00033 #include <QHash>
00034 #include <QTcpServer>
00035 #include <QTcpSocket>
00036
00037
00039 class Conexion : public QTcpSocket
00040 {
00041 Q_OBJECT
00042
00043 public:
00044 Conexion (int descriptor);
00045 ~Conexion ();
00046
00047 void Escribe (const QString &texto);
00048
00049 signals:
00050 void EliminarConexion (Conexion *con);
00051
00052 private slots:
00053 void ConexionCerrada ();
00054 void Lee ();
00055
00056 public:
00058 int descriptor;
00060 QString *direccion;
00061 };
00062
00064 class Servidor : public QTcpServer
00065 {
00066 Q_OBJECT
00067
00068 public:
00069 Servidor ();
00070 ~Servidor ();
00071
00072 void CierraConexion (const int descriptor);
00073 void Escribe (const int descriptor, const QString &texto);
00074 void incomingConnection (int descriptor);
00075
00076 private:
00078 QHash<int, Conexion *> conexiones;
00079
00080 private slots:
00081 void EliminarConexion (Conexion *con);
00082 };
00083
00084
00085 #endif // _SERVIDOR_HPP