3es  0.7
3estcpsocket.h
1 //
2 // author: Kazys Stepanas
3 //
4 #ifndef TCPSOCKET_H_
5 #define TCPSOCKET_H_
6 
7 #include "3es-core.h"
8 
9 #include <cstddef>
10 
11 namespace tes
12 {
13  struct TcpSocketDetail;
14 
16  class _3es_coreAPI TcpSocket
17  {
18  public:
20  static const unsigned IndefiniteTimeout;
21 
23  TcpSocket();
25  TcpSocket(TcpSocketDetail *detail);
27  ~TcpSocket();
28 
33  bool open(const char *host, unsigned short port);
34 
36  void close();
37 
42  bool isConnected() const;
43 
46  void setNoDelay(bool noDelay);
47 
50  bool noDelay() const;
51 
58  void setReadTimeout(unsigned timeoutMs);
59 
63  unsigned readTimeout() const;
64 
67  void setIndefiniteReadTimeout();
68 
73  void setWriteTimeout(unsigned timeoutMs);
74 
78  unsigned writeTimeout() const;
79 
82  void setIndefiniteWriteTimeout();
83 
86  void setReadBufferSize(int bufferSize);
87 
89  int readBufferSize() const;
90 
93  void setSendBufferSize(int bufferSize);
94 
96  int sendBufferSize() const;
97 
105  int read(char *buffer, int bufferLength) const;
106 
108  inline int read(unsigned char *buffer, int bufferLength) const { return read((char*)buffer, bufferLength); }
109 
115  int readAvailable(char *buffer, int bufferLength) const;
116 
118  inline int readAvailable(unsigned char *buffer, int bufferLength) const { return readAvailable((char*)buffer, bufferLength); }
119 
125  int write(const char *buffer, int bufferLength) const;
126 
128  inline int write(const unsigned char *buffer, int bufferLength) const { return write((const char*)buffer, bufferLength); }
129 
130  unsigned short port() const;
131 
132  private:
133  TcpSocketDetail *_detail;
134  };
135 }
136 
137 #endif // TCPSOCKET_H_
int readAvailable(unsigned char *buffer, int bufferLength) const
Definition: 3estcpsocket.h:118
int write(const unsigned char *buffer, int bufferLength) const
Definition: 3estcpsocket.h:128
Definition: 3esbounds.h:13
int read(unsigned char *buffer, int bufferLength) const
Definition: 3estcpsocket.h:108
static const unsigned IndefiniteTimeout
Value used to signify an indefinite timeout.
Definition: 3estcpsocket.h:20
A TCP/IP communication socket implementation.
Definition: 3estcpsocket.h:16
Definition: qt/3estcpdetail.h:15