Async  1.5.0
AsyncTcpClient.h
Go to the documentation of this file.
1 
36 #ifndef ASYNC_TCP_CLIENT_INCLUDED
37 #define ASYNC_TCP_CLIENT_INCLUDED
38 
39 
40 /****************************************************************************
41  *
42  * System Includes
43  *
44  ****************************************************************************/
45 
46 #include <sigc++/sigc++.h>
47 #include <stdint.h>
48 
49 #include <string>
50 
51 
52 /****************************************************************************
53  *
54  * Project Includes
55  *
56  ****************************************************************************/
57 
58 #include <AsyncTcpClientBase.h>
59 
60 
61 /****************************************************************************
62  *
63  * Local Includes
64  *
65  ****************************************************************************/
66 
67 
68 
69 /****************************************************************************
70  *
71  * Forward declarations
72  *
73  ****************************************************************************/
74 
75 
76 
77 /****************************************************************************
78  *
79  * Namespace
80  *
81  ****************************************************************************/
82 
83 namespace Async
84 {
85 
86 /****************************************************************************
87  *
88  * Forward declarations of classes inside of the declared namespace
89  *
90  ****************************************************************************/
91 
92 class FdWatch;
93 class DnsLookup;
94 class IpAddress;
95 
96 
97 /****************************************************************************
98  *
99  * Defines & typedefs
100  *
101  ****************************************************************************/
102 
103 
104 
105 /****************************************************************************
106  *
107  * Exported Global Variables
108  *
109  ****************************************************************************/
110 
111 
112 
113 /****************************************************************************
114  *
115  * Class definitions
116  *
117  ****************************************************************************/
118 
130 template <typename ConT=TcpConnection>
131 class TcpClient : public ConT, public TcpClientBase
132 {
133  public:
144  explicit TcpClient(size_t recv_buf_len = ConT::DEFAULT_RECV_BUF_LEN)
145  : ConT(recv_buf_len), TcpClientBase(this)
146  {
147  }
148 
159  TcpClient(const std::string& remote_host, uint16_t remote_port,
160  size_t recv_buf_len = ConT::DEFAULT_RECV_BUF_LEN)
161  : ConT(recv_buf_len), TcpClientBase(this, remote_host, remote_port)
162  {
163  }
164 
175  TcpClient(const IpAddress& remote_ip, uint16_t remote_port,
176  size_t recv_buf_len = ConT::DEFAULT_RECV_BUF_LEN)
177  : ConT(recv_buf_len), TcpClientBase(this, remote_ip, remote_port)
178  {
179  }
180 
184  ~TcpClient(void) {}
185 
193  virtual void disconnect(void)
194  {
195  ConT::disconnect();
197  }
198 
205  bool isIdle(void) const
206  {
207  return TcpClientBase::isIdle() && ConT::isIdle();
208  }
209 
210  protected:
211 
212  private:
213 
214 }; /* class TcpClient */
215 
216 
217 } /* namespace */
218 
219 #endif /* ASYNC_TCP_CLIENT_INCLUDED */
220 
221 
222 
223 /*
224  * This file has not been truncated
225  */
226 
bool isIdle(void) const
Check if the connection is idle.
A base class for creating a TCP client connection.
Contains a base class for creating TCP client connections.
bool isIdle(void) const
Check if the connection is idle.
A class for creating a TCP client connection.
TcpClient(const std::string &remote_host, uint16_t remote_port, size_t recv_buf_len=ConT::DEFAULT_RECV_BUF_LEN)
Constructor.
TcpClient(size_t recv_buf_len=ConT::DEFAULT_RECV_BUF_LEN)
Constructor.
~TcpClient(void)
Destructor.
Namespace for the asynchronous programming classes.
void disconnect(void)
Disconnect from the remote host.
A class for representing an IP address in an OS independent way.
virtual void disconnect(void)
Disconnect from the remote host.
TcpClient(const IpAddress &remote_ip, uint16_t remote_port, size_t recv_buf_len=ConT::DEFAULT_RECV_BUF_LEN)
Constructor.