C++ IP API  9.5.8
TCP & UDP for virtual user scripts
Facilita::TcpClientConnection Class Reference

This class enables communication over the TCP protocol and permits connection to a server. More...

Inheritance diagram for Facilita::TcpClientConnection:
Collaboration diagram for Facilita::TcpClientConnection:

Public Methods

 TcpClientConnection ()
 Default constructor. More...
 
 TcpClientConnection (const TcpClientConnection &other)
 Copy constructor. More...
 
void connect ()
 Open a connection. If the connection is already open then this method returns immediately. The timeout period is the value of ConnectTimeout property.

Exceptions
TimeoutExceptionthrown when the timeout period is exceeded.
More...
 
TcpClientConnectionoperator= (const TcpClientConnection &other)
 Assignment operator for this class. More...
 
- Public Methods inherited from Facilita::TcpConnection
 TcpConnection ()
 Default constructor (not called directly by user written code). More...
 
 TcpConnection (const TcpConnection &other)
 Copy constructor. More...
 
int getConnectRetries () const
 Get the number of times a connection request will be retried if unsuccessful. More...
 
TcpConnectionoperator= (const TcpConnection &other)
 Assignment operator. More...
 
void setConnectRetries (int retries)
 Set the number of times a connection request will be retried if unsuccessful. More...
 
void disconnect (ActionType failAction=ACT_RAISE_EXCEPTION)
 
void send (const string &text, int reference=0, ActionType failAction=ACT_RAISE_EXCEPTION)
 Send data string. More...
 
ReceiveResponse receive (int nBytes, ActionType failAction=ACT_RAISE_EXCEPTION)
 Receive (read and return) a specified number of bytes. More...
 
ReceiveResponse receive (const string &text, ActionType failAction=ACT_RAISE_EXCEPTION)
 Receive (read and return) data up to and including the string argument to this method, but no more than the maximum stipulated in the property Buffersize. A call will terminate with an error if the target string has not been matched within the time period defined by the property ReceiveTimeout. This method will only read up to a maximum number of bytes set in the property Buffersize and will indicate an error if the match has not occurred. More...
 
PatternResponse receive (Pattern &pattern, ActionType failAction=ACT_RAISE_EXCEPTION)
 Receive (read and return) a string of bytes up to and including the pattern specified. This method will only read up to a maximum number of bytes set in the property Buffersize. A call will terminate with an error if the match has not occurred within the time period defined by the property ReceiveTimeout. More...
 
PatternResponse unblockedReceive (Pattern &pattern, ActionType failAction=ACT_RAISE_EXCEPTION)
 Receive (return) a string of bytes up to and including the pattern specified from data already read from the underling socket. More...
 
int clearBuffer ()
 Clear (throw away) all data currently held for this connection. No read from the underlying socket is made by this call. More...
 
DiscardResponse discardUpto (const string &text, ActionType failAction=ACT_RAISE_EXCEPTION)
 Discard (read and throw away) bytes up to and including the string specified. More...
 
DiscardResponse discardUpto (Pattern &pattern, ActionType failAction=ACT_RAISE_EXCEPTION)
 Discard (read and throw away) bytes up to and including the pattern specified. More...
 
DiscardResponse discard (int nBytes, ActionType failAction=ACT_RAISE_EXCEPTION)
 Discard (read and throw away) a specific number of bytes of data. Data may be read from the underlying communications layer. More...
 
DiscardResponse discardForTimePeriod (long millis, ActionType failAction=ACT_RAISE_EXCEPTION)
 Read and throwaway bytes all data received within the given time. This includes any data that is already held by this connection. More...
 
int getBufferSize () const
 Get the size of the buffer used to receive data from the network. More...
 
void setBufferSize (int bufferSize)
 Set the current buffer size. More...
 
int getDnsTimeout () const
 Get the DNS look up timeout value (the maximum time that will be spent looking up an IP address). More...
 
void setDnsTimeout (int timeout)
 Set the DNS look up timeout value (the maximum time that will be spent looking up an IP address). More...
 
int getDnsRetries () const
 Get the number of times a DNS lookup is attempted before giving up. More...
 
void setDnsRetries (int retries)
 Set the number of DNS lookup retries that can be made. More...
 
int getReceiveTimeout () const
 Get the the maximum time to be spent waiting for data to satisfy a receive/discard request More...
 
void setReceiveTimeout (int timeout)
 Set the receive timeout. More...
 
int getConnectTimeout () const
 Get the maximum time to be spent waiting for the response to a connection request. More...
 
void setConnectTimeout (int timeout)
 Set the maximum time to be spent waiting for the response to a connection request. More...
 
bool isLoggingEnabled () const
 Read only, indicates if logging is enabled. More...
 
int getSendTimeout () const
 Get the timeout used whilst waiting for data to be sent. More...
 
void setSendTimeout (int timeout)
 Set the send timeout. More...
 
DataRatePacer & getDataRate () const
 Get the maximum rate (kilobits per second) at which data will be transferred over this connection. A negative value or 0 means no limit. This feature provides a basic and unsophisticated way of simulating traffic over slow networks and this type of simulation is no match for dedicated network simulation tools. More...
 
void setDataRate (int dataRate)
 Set the maximum rate (kilobits per second) at which data will be transferred over this connection. A negative value or 0 means no limit. This feature provides a basic and unsophisticated way of simulating traffic over slow networks and this type of simulation is no match for dedicated network simulation tools. More...
 
IpEndPoint getRemoteIpEndPoint () const
 Get the remote IpEndPoint. More...
 
IpEndPoint getLocalIpEndPoint () const
 Get the local IpEndPoint. More...
 
void suspendLogging ()
 
void resumeLogging ()
 
string toString () const
 A short string describing this object. More...
 
int getConnectionNumber ()
 Get the connection number. More...
 

Detailed Description

This class enables communication over the TCP protocol and permits connection to a server.

This class enables communication over the TCP protocol. Functioning objects of this class are not created directly, but from calls to factory methods on an IpScript. A TcpClientConnection object must be connected, by a call to connect, before data can be sent or received without error. Objects of this class are safe to be copied and re-assigned. They are not thread-safe.

Constructors

Facilita::TcpClientConnection::TcpClientConnection ( )

Default constructor.

Facilita::TcpClientConnection::TcpClientConnection ( const TcpClientConnection other)

Copy constructor.

Methods

void Facilita::TcpClientConnection::connect ( )

Open a connection. If the connection is already open then this method returns immediately. The timeout period is the value of ConnectTimeout property.

Exceptions
TimeoutExceptionthrown when the timeout period is exceeded.

TcpClientConnection& Facilita::TcpClientConnection::operator= ( const TcpClientConnection other)

Assignment operator for this class.

Returns
The this object.

The documentation for this class was generated from the following file: