AsyncTcpServer.h

Go to the documentation of this file.
00001 
00034 #ifndef ASYNC_TCP_SERVER_INCLUDED
00035 #define ASYNC_TCP_SERVER_INCLUDED
00036 
00037 
00038 /****************************************************************************
00039  *
00040  * System Includes
00041  *
00042  ****************************************************************************/
00043 
00044 #include <string>
00045 #include <vector>
00046 #include <sigc++/sigc++.h>
00047 
00048 
00049 /****************************************************************************
00050  *
00051  * Project Includes
00052  *
00053  ****************************************************************************/
00054 
00055 #include <AsyncTcpConnection.h>
00056 
00057 
00058 /****************************************************************************
00059  *
00060  * Local Includes
00061  *
00062  ****************************************************************************/
00063 
00064 
00065 
00066 /****************************************************************************
00067  *
00068  * Forward declarations
00069  *
00070  ****************************************************************************/
00071 
00072 
00073 
00074 /****************************************************************************
00075  *
00076  * Namespace
00077  *
00078  ****************************************************************************/
00079 
00080 namespace Async
00081 {
00082 
00083 /****************************************************************************
00084  *
00085  * Forward declarations of classes inside of the declared namespace
00086  *
00087  ****************************************************************************/
00088 
00089 class FdWatch;
00090   
00091 
00092 /****************************************************************************
00093  *
00094  * Defines & typedefs
00095  *
00096  ****************************************************************************/
00097 
00098 
00099 
00100 /****************************************************************************
00101  *
00102  * Exported Global Variables
00103  *
00104  ****************************************************************************/
00105 
00106 
00107 
00108 /****************************************************************************
00109  *
00110  * Class definitions
00111  *
00112  ****************************************************************************/
00113 
00126 class TcpServer : public SigC::Object
00127 {
00128   public:
00133     TcpServer(const std::string& port_str);
00134   
00138     ~TcpServer(void);
00139   
00144     int numberOfClients(void);
00145 
00151     TcpConnection *getClient(unsigned int index);
00152 
00159     int writeAll(const void *buf, int count);
00160 
00168     int writeOnly(TcpConnection *con, const void *buf, int count);
00169 
00177     int writeExcept(TcpConnection *con, const void *buf, int count);
00178 
00183     SigC::Signal1<void, TcpConnection *>  clientConnected;
00184   
00190     SigC::Signal2<void, TcpConnection *,TcpConnection::DisconnectReason>
00191             clientDisconnected;
00192   
00193   
00194   protected:
00195     
00196   private:
00197     typedef std::vector<TcpConnection*> TcpConnectionList;
00198     
00199     int               sock;
00200     FdWatch           *rd_watch;
00201     TcpConnectionList tcpConnectionList;
00202     
00203     void cleanup(void);
00204     void onConnection(FdWatch *watch);
00205     void onDisconnected(TcpConnection *con,
00206                         TcpConnection::DisconnectReason reason);
00207     
00208 };  /* class TcpServer */
00209 
00210 
00211 } /* namespace */
00212 
00213 #endif /* ASYNC_TCP_SERVER_INCLUDED */
00214 
00215 
00216 
00217 /*
00218  * This file has not been truncated
00219  */
00220 
00221 
00222 
Generated by  doxygen 1.6.2-20100208