Async  1.5.0
AsyncTcpClientBase.h
Go to the documentation of this file.
1 
30 #ifndef ASYNC_TCP_CLIENT_BASE_INCLUDED
31 #define ASYNC_TCP_CLIENT_BASE_INCLUDED
32 
33 
34 /****************************************************************************
35  *
36  * System Includes
37  *
38  ****************************************************************************/
39 
40 #include <sigc++/sigc++.h>
41 #include <stdint.h>
42 
43 #include <string>
44 
45 
46 /****************************************************************************
47  *
48  * Project Includes
49  *
50  ****************************************************************************/
51 
52 #include <AsyncTcpConnection.h>
53 
54 
55 /****************************************************************************
56  *
57  * Local Includes
58  *
59  ****************************************************************************/
60 
61 
62 
63 /****************************************************************************
64  *
65  * Forward declarations
66  *
67  ****************************************************************************/
68 
69 
70 
71 /****************************************************************************
72  *
73  * Namespace
74  *
75  ****************************************************************************/
76 
77 namespace Async
78 {
79 
80 /****************************************************************************
81  *
82  * Forward declarations of classes inside of the declared namespace
83  *
84  ****************************************************************************/
85 
86 class FdWatch;
87 class DnsLookup;
88 class IpAddress;
89 
90 
91 /****************************************************************************
92  *
93  * Defines & typedefs
94  *
95  ****************************************************************************/
96 
97 
98 
99 /****************************************************************************
100  *
101  * Exported Global Variables
102  *
103  ****************************************************************************/
104 
105 
106 
107 /****************************************************************************
108  *
109  * Class definitions
110  *
111  ****************************************************************************/
112 
122 {
123  public:
134  explicit TcpClientBase(TcpConnection *con);
135 
146  TcpClientBase(TcpConnection *con, const std::string& remote_host,
147  uint16_t remote_port);
148 
159  TcpClientBase(TcpConnection *con, const IpAddress& remote_ip,
160  uint16_t remote_port);
161 
165  ~TcpClientBase(void);
166 
171  void bind(const IpAddress& bind_ip);
172 
183  void connect(const std::string &remote_host, uint16_t remote_port);
184 
195  void connect(const Async::IpAddress& remote_ip, uint16_t remote_port);
196 
205  void connect(void);
206 
214  void disconnect(void);
215 
222  bool isIdle(void) const { return (sock == -1); }
223 
227  sigc::signal<void> connected;
228 
229  protected:
230 
231  private:
232  TcpConnection * con;
233  DnsLookup * dns;
234  std::string remote_host;
235  int sock;
236  FdWatch * wr_watch;
237  Async::IpAddress bind_ip;
238 
239  void dnsResultsReady(DnsLookup& dns_lookup);
240  void connectToRemote(void);
241  void connectHandler(FdWatch *watch);
242 
243 }; /* class TcpClientBase */
244 
245 
246 } /* namespace */
247 
248 #endif /* ASYNC_TCP_CLIENT_BASE_INCLUDED */
249 
250 
251 
252 /*
253  * This file has not been truncated
254  */
255 
bool isIdle(void) const
Check if the connection is idle.
A class for handling exiting TCP connections.
A base class for creating a TCP client connection.
void bind(const IpAddress &bind_ip)
Bind to the interface having the specified IP address.
TcpClientBase(TcpConnection *con)
Constructor.
sigc::signal< void > connected
A signal that is emitted when a connection has been established.
A class for watching file descriptors.
Definition: AsyncFdWatch.h:119
Contains a class for handling exiting TCP connections.
void connect(void)
Connect to the remote host.
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.
A class for performing asynchronous DNS lookups.
~TcpClientBase(void)
Destructor.