CARMA C++
TcpClient.h
Go to the documentation of this file.
1 #ifndef TCPCLIENT_H
2 #define TCPCLIENT_H
3 
11 #include "carma/szautil/Port.h"
12 
13 #include <string>
14 
15 namespace sza {
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  virtual 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  return 0;
67  };
68 
72  virtual void disconnect();
73 
77  bool isConnected();
78 
79  private:
80 
81  // True when host and port number have been initialized.
82 
83  bool hostInitialized_;
84  bool portInitialized_;
85 
86  // True when connected to the server.
87 
88  bool connected_;
89 
90  // The host to connect to
91 
92  std::string host_;
93 
94  // The port to connect to
95 
96  unsigned port_;
97 
101  virtual int privateConnectToServer(bool doWait);
102 
103  }; // End class TcpClient
104 
105  }; // End namespace util
106 }; // End namespace sza
107 
108 #endif // End #ifndef
109 
110 
Tagged: Mon May 10 16:41:20 PDT 2004.