C++ IP API
9.5.8
TCP & UDP for virtual user scripts
|
A TCP protocol connection endpoint that manages an underlying socket. Provides methods for sending and receiving data that are designed for use in test scripts More...
Public Methods | |
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... | |
TcpConnection & | operator= (const TcpConnection &other) |
Assignment operator. More... | |
void | setConnectRetries (int retries) |
Set the number of times a connection request will be retried if unsuccessful. More... | |
Public Methods For Connecting, Sending And Receiving Data | |
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... | |
A TCP protocol connection endpoint that manages an underlying socket. Provides methods for sending and receiving data that are designed for use in test scripts
TcpConnection objects are not created directly, use IpScript or IpVirtualUser factory methods.
Objects of this class can be copied and re-assigned. They are not thread-safe.
Facilita::TcpConnection::TcpConnection | ( | ) |
Default constructor (not called directly by user written code).
Facilita::TcpConnection::TcpConnection | ( | const TcpConnection & | other | ) |
Copy constructor.
int Facilita::TcpConnection::clearBuffer | ( | ) |
Clear (throw away) all data currently held for this connection. No read from the underlying socket is made by this call.
DiscardResponse Facilita::TcpConnection::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.
nBytes | The number of bytes to discard. |
failAction | Action to be taken on failure. It is reported as a failure if fewer bytes are discarded than requested. |
DiscardResponse Facilita::TcpConnection::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.
millis | time in milliseconds to read and discard data. |
failAction | Action to be taken on failure. |
DiscardResponse Facilita::TcpConnection::discardUpto | ( | const string & | text, |
ActionType | failAction = ACT_RAISE_EXCEPTION |
||
) |
Discard (read and throw away) bytes up to and including the string specified.
text | The string to match the end of the data to be discarded. |
failAction | Action to be taken on failure. |
DiscardResponse Facilita::TcpConnection::discardUpto | ( | Pattern & | pattern, |
ActionType | failAction = ACT_RAISE_EXCEPTION |
||
) |
Discard (read and throw away) bytes up to and including the pattern specified.
pattern | A pattern object to match the end of the data to be discarded. |
failAction | Action to be taken on failure. |
void Facilita::TcpConnection::disconnect | ( | ActionType | failAction = ACT_RAISE_EXCEPTION | ) |
Disconnect this connection. If the TcpConnection is not connected then this method does nothing.
failAction | Action to be taken on failure. |
int Facilita::TcpConnection::getBufferSize | ( | ) | const |
Get the size of the buffer used to receive data from the network.
int Facilita::TcpConnection::getConnectionNumber | ( | ) |
Get the connection number.
int Facilita::TcpConnection::getConnectRetries | ( | ) | const |
Get the number of times a connection request will be retried if unsuccessful.
int Facilita::TcpConnection::getConnectTimeout | ( | ) | const |
Get the maximum time to be spent waiting for the response to a connection request.
DataRatePacer& Facilita::TcpConnection::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.
int Facilita::TcpConnection::getDnsRetries | ( | ) | const |
Get the number of times a DNS lookup is attempted before giving up.
int Facilita::TcpConnection::getDnsTimeout | ( | ) | const |
Get the DNS look up timeout value (the maximum time that will be spent looking up an IP address).
IpEndPoint Facilita::TcpConnection::getLocalIpEndPoint | ( | ) | const |
Get the local IpEndPoint.
int Facilita::TcpConnection::getReceiveTimeout | ( | ) | const |
Get the the maximum time to be spent waiting for data to satisfy a receive/discard request
IpEndPoint Facilita::TcpConnection::getRemoteIpEndPoint | ( | ) | const |
Get the remote IpEndPoint.
int Facilita::TcpConnection::getSendTimeout | ( | ) | const |
Get the timeout used whilst waiting for data to be sent.
bool Facilita::TcpConnection::isLoggingEnabled | ( | ) | const |
Read only, indicates if logging is enabled.
TcpConnection& Facilita::TcpConnection::operator= | ( | const TcpConnection & | other | ) |
Assignment operator.
ReceiveResponse Facilita::TcpConnection::receive | ( | int | nBytes, |
ActionType | failAction = ACT_RAISE_EXCEPTION |
||
) |
Receive (read and return) a specified number of bytes.
The bytes read will not exceed the lesser of property Buffersize and the nBytes parameter. A call will terminate with an error if the full quota of bytes cannot be read within the time period defined by the property ReceiveTimeout.
nBytes | The number of bytes to attempt to read. |
failAction | Action to be taken on failure. |
ReceiveResponse Facilita::TcpConnection::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.
text | The string to match within the data. |
failAction | Action to be taken on failure. |
PatternResponse Facilita::TcpConnection::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.
pattern | A pattern object to match within the read data stream. |
failAction | Action to be taken on failure. |
void Facilita::TcpConnection::resumeLogging | ( | ) |
void Facilita::TcpConnection::send | ( | const string & | text, |
int | reference = 0 , |
||
ActionType | failAction = ACT_RAISE_EXCEPTION |
||
) |
Send data string.
text | The data. |
reference | A number to tag the call when logging the conversation. |
failAction | Action to be taken on failure. |
void Facilita::TcpConnection::setBufferSize | ( | int | bufferSize | ) |
Set the current buffer size.
bufferSize | The number of bytes to set the buffer size. |
void Facilita::TcpConnection::setConnectRetries | ( | int | retries | ) |
Set the number of times a connection request will be retried if unsuccessful.
retries | Set this number of retries. |
void Facilita::TcpConnection::setConnectTimeout | ( | int | timeout | ) |
Set the maximum time to be spent waiting for the response to a connection request.
timeout | The timeout value in milliseconds. |
void Facilita::TcpConnection::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.
dataRate | The rate expressed as kilobits per second. |
void Facilita::TcpConnection::setDnsRetries | ( | int | retries | ) |
Set the number of DNS lookup retries that can be made.
retries | The number retries that can be made on a DNS look up. |
void Facilita::TcpConnection::setDnsTimeout | ( | int | timeout | ) |
Set the DNS look up timeout value (the maximum time that will be spent looking up an IP address).
timeout | The DNS look up timeout in milliseconds. |
void Facilita::TcpConnection::setReceiveTimeout | ( | int | timeout | ) |
Set the receive timeout.
timeout | The timeout value in milliseconds. |
void Facilita::TcpConnection::setSendTimeout | ( | int | timeout | ) |
Set the send timeout.
timeout | The new timeout value in milliseconds. |
void Facilita::TcpConnection::suspendLogging | ( | ) |
string Facilita::TcpConnection::toString | ( | ) | const |
A short string describing this object.
PatternResponse Facilita::TcpConnection::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.
Unlike the other receive methods this variant will not block reading data from the underlying socket. This call should be made when it is known or expected that the data has been sent by the remote peer.
pattern | A pattern object to match within the read data stream. |
failAction | Action to be taken on failure. |