Share this page

# lrs_set_recv_timeout2

Timeout Functions

Sets a timeout for receiving data on a socket after a connection was established.

    void lrs_set_recv_timeout2( long sec, long u_sec );

sec | The desired timeout in seconds.
u_sec | The desired timeout in microseconds (added to the sec parameter)

The lrs_set_recv_timeout2 function sets a timeout limit for receiving data on a socket. When lrs_receive receives the data buffer, it compares its size with the expected data. If the buffer size does not match, it performs additional iterations and rereads the incoming socket data, until the timeout2 limit is reached. You can view these iterations in the full log trace.

This function allows you to customize the behavior of your script for different types of applications:

For example, applications that require a relatively long time for a reply, but once the server replies, the data is received at a quicker rate. In such a case, you can set the connection timeout using lrs_set_recv_timeout to a high limit, and the timeout for subsequent iterations to a lower limit using lrs_set_recv_timeout2. For example, when you perform a query on a database server, it may take time for the server to process your request and return data. However, once the server begins to send data, it continues sending with almost no delay. Therefore, the receive timeout for the remainder of the data, timeout2, should be decreased.

Other applications connect to the server quickly, but the data transfer requires a longer period of time, such as in a heavily loaded network. In this case, you set lrs_set_recv_timeout to a low value and timeout2 to a higher value.

## Return Values

This function has no return value.

## Parameterization

You cannot use standard parameterization for any arguments in this function.

## Example

In the following example, lrs_set_recv_timeout specifies a timeout of 120 seconds for a login procedure. Once the connection is established, the data streams at a quicker rate. The lrs_recv_timeout2 function sets the timeout for subsequent iterations to 10 seconds.

    lrs_create_socket("socket2", "TCP", "RemoteHost=tears.abc.co.il:23", LrsLastArg);

    lrs_send("socket2", "buf2", LrsLastArg);

    lrs_set_recv_timeout(120,0);

    lrs_set_recv_timeout2(10,0);

    lrs_receive("socket2", "buf3", LrsLastArg);

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: