Async 1.7.0
AsyncTcpClient.h
Go to the documentation of this file.
1
29
33
34
35
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
83namespace Async
84{
85
86/****************************************************************************
87 *
88 * Forward declarations of classes inside of the declared namespace
89 *
90 ****************************************************************************/
91
92class FdWatch;
93class DnsLookup;
94class 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
130template <typename ConT=TcpConnection>
131class 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) override { closeConnection(); }
194
201 bool isIdle(void) const
202 {
203 return TcpClientBase::isIdle() && ConT::isIdle();
204 }
205
206 protected:
213 virtual void closeConnection(void) override
214 {
215 ConT::closeConnection();
217 }
218
219 using ConT::operator=;
220 using TcpClientBase::operator=;
221
222 private:
223
224}; /* class TcpClient */
225
226
227} /* namespace */
228
229#endif /* ASYNC_TCP_CLIENT_INCLUDED */
230
231
232
233/*
234 * This file has not been truncated
235 */
236
Contains a base class for creating TCP client connections.
A class for performing asynchronous DNS lookups.
A class for watching file descriptors.
A class for representing an IP address in an OS independent way.
virtual void closeConnection(void)
Disconnect from the remote peer.
bool isIdle(void) const
Check if the connection is idle.
bool isIdle(void) const
Check if the connection is idle.
~TcpClient(void)
Destructor.
virtual void closeConnection(void) override
Disconnect from the remote peer.
TcpClient(const IpAddress &remote_ip, uint16_t remote_port, size_t recv_buf_len=ConT::DEFAULT_RECV_BUF_LEN)
Constructor.
virtual void disconnect(void) override
Disconnect from the remote host.
TcpClient(size_t recv_buf_len=ConT::DEFAULT_RECV_BUF_LEN)
Constructor.
TcpClient(const std::string &remote_host, uint16_t remote_port, size_t recv_buf_len=ConT::DEFAULT_RECV_BUF_LEN)
Constructor.
Namespace for the asynchronous programming classes.