Async 1.8.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
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
207 {
208 ConT::setSslContext(ctx, false);
209 }
210
211 protected:
218 virtual void closeConnection(void) override
219 {
220 ConT::closeConnection();
222 }
223
224 using ConT::operator=;
225 using TcpClientBase::operator=;
226
227 private:
228
229}; /* class TcpClient */
230
231
232} /* namespace */
233
234#endif /* ASYNC_TCP_CLIENT_INCLUDED */
235
236
237
238/*
239 * This file has not been truncated
240 */
241
Contains a base class for creating TCP client connections.
A class for representing an IP address in an OS independent way.
SSL context meant to be used with TcpConnection and friends.
A base class for creating a TCP client connection.
virtual void closeConnection(void)
Check if the connection has been fully connected.
bool isIdle(void) const
Check if the connection is idle.
A class for creating a TCP client connection.
bool isIdle(void) const
Check if the connection is idle.
~TcpClient(void)
Destructor.
virtual void closeConnection(void) override
Disconnect from the remote peer.
void setSslContext(SslContext &ctx)
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.