My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
TcpClient.h
Go to the documentation of this file.
1 #ifndef TCPCLIENT_H
2 #define TCPCLIENT_H
3 
11 #include "gcp/util/common/Port.h"
12 
13 #include <string>
14 
15 namespace gcp {
16  namespace util {
17 
18  class TcpClient : public Port {
19  public:
20 
24  TcpClient();
25 
29  TcpClient(std::string host, unsigned port);
30 
34  virtual ~TcpClient();
35 
39  int connectToServer(bool doWait);
40 
44  int connectToServer(std::string host, unsigned port, bool doWait);
45 
50  void setBlocking(bool doWait);
51 
55  void setHost(std::string host);
56 
60  void setPort(unsigned port);
61 
65  int connect() {};
66 
70  void disconnect();
71 
75  bool isConnected();
76 
77  std::string getHost() {
78  return host_;
79  }
80 
81  unsigned int getPort() {
82  return port_;
83  }
84 
85  private:
86 
87  // True when connected to the server.
88 
89  bool connected_;
90 
91  // The host to connect to
92 
93  std::string host_;
94  bool hostInit_;
95 
96  // The port to connect to
97 
98  unsigned port_;
99  bool portInit_;
100 
104  int privateConnectToServer(bool doWait);
105 
106  }; // End class TcpClient
107 
108  } // End namespace util
109 } // End namespace gcp
110 
111 
112 #endif // End #ifndef
113 
114 
TcpClient()
Definition: TcpClient.cc:18
Definition: Port.h:19
Definition: TcpClient.h:18
void setBlocking(bool doWait)
Definition: TcpClient.cc:139
int connect()
Definition: TcpClient.h:65
void setHost(std::string host)
Definition: TcpClient.cc:112
int connectToServer(bool doWait)
Definition: TcpClient.cc:60
void setPort(unsigned port)
Definition: TcpClient.cc:121
bool isConnected()
Definition: TcpClient.cc:130
virtual ~TcpClient()
Definition: TcpClient.cc:41
void disconnect()
Definition: TcpClient.cc:98