C++ IP API  9.5.7
TCP & UDP for virtual user scripts
TcpConnection.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Ip.h"
4 #include "TcpConnectionInterface.h"
5 #include "TcpPropertiesInterface.h"
6 #include "TcpConnectionImpl.h"
7 #include "Action.h"
8 #include "DataRatePacer.h"
9 #include "IpLinkInterface.h"
10 #include <memory>
11 
12 namespace Facilita
13 {
23  #pragma warning (disable : 4638)
24  class IP_API TcpConnection : public TcpConnectionInterface, TcpPropertiesInterface, IpLinkInterface
25  {
26  friend class TcpClientConnection;
27  friend class TcpConnectionFactory;
28 
29  public:
31  TcpConnection();
33  TcpConnection(const TcpConnection& other);
36  TcpConnection& operator=(const TcpConnection& other);
40 
45  void disconnect(ActionType failAction=ACT_RAISE_EXCEPTION);
54  void send(const string& text, int reference=0, ActionType failAction=ACT_RAISE_EXCEPTION);
55 
66  ReceiveResponse receive(int nBytes, ActionType failAction=ACT_RAISE_EXCEPTION);
67 
78  ReceiveResponse receive(const string& text, ActionType failAction=ACT_RAISE_EXCEPTION);
79 
90  PatternResponse receive(Pattern& pattern, ActionType failAction=ACT_RAISE_EXCEPTION);
91 
105  PatternResponse unblockedReceive(Pattern& pattern, ActionType failAction=ACT_RAISE_EXCEPTION);
106 
113  int clearBuffer();
114 
123  DiscardResponse discardUpto(const string& text, ActionType failAction=ACT_RAISE_EXCEPTION);
124 
133  DiscardResponse discardUpto(Pattern& pattern, ActionType failAction=ACT_RAISE_EXCEPTION);
134 
143  DiscardResponse discard(int nBytes, ActionType failAction=ACT_RAISE_EXCEPTION);
144 
154  DiscardResponse discardForTimePeriod(long millis, ActionType failAction=ACT_RAISE_EXCEPTION);
156 
160 
165  int getBufferSize() const ;
168  void setBufferSize(int bufferSize);
173  int getDnsTimeout() const;
176  void setDnsTimeout(int timeout);
181  int getDnsRetries() const;
184  void setDnsRetries(int retries);
189  int getReceiveTimeout() const;
192  void setReceiveTimeout(int timeout);
197  int getConnectTimeout() const;
200  void setConnectTimeout(int timeout);
205  bool isLoggingEnabled() const;
209  int getConnectRetries() const;
212  void setConnectRetries(int retries);
217  int getSendTimeout() const;
220  void setSendTimeout(int timeout);
225  DataRatePacer& getDataRate() const;
228  void setDataRate(int dataRate);
233  IpEndPoint getRemoteIpEndPoint() const;
236  IpEndPoint getLocalIpEndPoint() const;
237 
238  void suspendLogging();
239  void resumeLogging();
240 
243  string toString() const;
246  int getConnectionNumber();
248  private:
249  TcpConnection(TcpConnectionImpl* impl);
250 
251 #pragma warning(disable:4251)
252  shared_ptr<TcpConnectionImpl> _impl;
253 #pragma warning(default:4251)
254  VirtualUserInterface* vu;
255 
256  };
257 }
A factory class for the creation of TcpClientConnection and TcpConnection objects.
Definition: TcpConnectionFactory.h:24
Objects of this class are returned by discard methods.
Definition: IpResponses.h:59
This class encapsulates IP address and port. Static member instances represent common patterns and ad...
Definition: IpEndPoint.h:20
An Interface to which sub-classes must conform.
Definition: Pattern.h:13
This class enables communication over the TCP protocol and permits connection to a server...
Definition: TcpClientConnection.h:18
#define IP_API
Definition: Ip.h:21
Objects of this class are returned by receive methods.
Definition: IpResponses.h:89
Definition: IpEndPoint.h:9
A TCP protocol connection endpoint that manages an underlying socket. Provides methods for sending an...
Definition: TcpConnection.h:24
The objects of this class are returned by receive methods.
Definition: IpResponses.h:115