00001 00036 #ifndef ASYNC_TCP_CLIENT_INCLUDED 00037 #define ASYNC_TCP_CLIENT_INCLUDED 00038 00039 00040 /**************************************************************************** 00041 * 00042 * System Includes 00043 * 00044 ****************************************************************************/ 00045 00046 #include <sigc++/signal_system.h> 00047 00048 #include <string> 00049 00050 00051 /**************************************************************************** 00052 * 00053 * Project Includes 00054 * 00055 ****************************************************************************/ 00056 00057 #include <AsyncTcpConnection.h> 00058 00059 00060 /**************************************************************************** 00061 * 00062 * Local Includes 00063 * 00064 ****************************************************************************/ 00065 00066 00067 00068 /**************************************************************************** 00069 * 00070 * Forward declarations 00071 * 00072 ****************************************************************************/ 00073 00074 00075 00076 /**************************************************************************** 00077 * 00078 * Namespace 00079 * 00080 ****************************************************************************/ 00081 00082 namespace Async 00083 { 00084 00085 /**************************************************************************** 00086 * 00087 * Forward declarations of classes inside of the declared namespace 00088 * 00089 ****************************************************************************/ 00090 00091 class FdWatch; 00092 class DnsLookup; 00093 class IpAddress; 00094 00095 00096 /**************************************************************************** 00097 * 00098 * Defines & typedefs 00099 * 00100 ****************************************************************************/ 00101 00102 00103 00104 /**************************************************************************** 00105 * 00106 * Exported Global Variables 00107 * 00108 ****************************************************************************/ 00109 00110 00111 00112 /**************************************************************************** 00113 * 00114 * Class definitions 00115 * 00116 ****************************************************************************/ 00117 00129 class TcpClient : public TcpConnection 00130 { 00131 public: 00142 TcpClient(const std::string& remote_host, unsigned short remote_port, 00143 size_t recv_buf_len = DEFAULT_RECV_BUF_LEN); 00144 00148 ~TcpClient(void); 00149 00158 void connect(void); 00159 00167 void disconnect(void); 00168 00172 SigC::Signal0<void> connected; 00173 00174 00175 protected: 00176 00177 private: 00178 DnsLookup *dns; 00179 std::string remote_host; 00180 unsigned short remote_port; 00181 int sock; 00182 FdWatch *wr_watch; 00183 00184 void dnsResultsReady(DnsLookup& dns_lookup); 00185 void connectToRemote(const IpAddress& ip_addr); 00186 void connectHandler(FdWatch *watch); 00187 00188 }; /* class TcpClient */ 00189 00190 00191 } /* namespace */ 00192 00193 #endif /* ASYNC_TCP_CLIENT_INCLUDED */ 00194 00195 00196 00197 /* 00198 * This file has not been truncated 00199 */ 00200
1.4.4