Share this page

# lrs_set_receive_option

Sockets Functions

Sets a socket receive option.

    int lrs_set_receive_option( int option, int value, [char *terminator]);

option | A receiving option indicating when to stop receiving. The available options are Mismatch or EndMarker.
value | The option value. (see the chart below)
terminator | The character(s) marking the end of the block to receive, in the format: "value ". This parameter is only required if StringTerminator was specified for the EndMarker option.

### Options

Option | Available Values
--- | ---
Mismatch | 1. MISMATCH_SIZE (default) 2. MISMATCH_CONTENT
EndMarker | 1. EndMarker_None (default) - receive until the end of the buffer. 2. StringTerminator - the terminating string. (TCP socket type only) 3. BinaryStringTerminator - the terminating string. (TCP socket type only) 4. RecordingSize - the size of the buffer that was recorded. (TCP socket type only)

The lrs_set_receive_option function sets a socket receiving option for lrs_receive. The options indicate to finish receiving socket information—either after a mismatch or when it detects a terminating string. Note that this option does not apply to any receive operations handled with lrs_receive_ex. The options set by this function apply to all occurrences of lrs_receive after this function, unless the option is reset by a subsequent call to lrs_set_receive_option.

This function is not recorded during a WinSock session—you manually insert it into your script.

## Return Values

Windows Sockets Return Values

## Parameterization

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

## Examples

### Example 1

In this example, the lrs_set_receive_option function indicates to the receiving socket that if a content mismatch occurs, it sends a mismatch message.

Suppose that the recorded buffer contains a character "!" and in replay the buffer contains "@"

Copy code

    lrs_set_receive_option(Mismatch, MISMATCH_CONTENT);
    lrs_send("socket1", "buf2", 1, 0);
    lrs_receive("socket1", "buf2", LrsLastArg);
    lrs_close_socket("socket1");

If the option value was MISMATCH_SIZE, then this function would not report an error, since the size is the same.

### Example 2

In the following example, the lrs_set_receive_option function indicates to the receiving socket that it should receive the same number of bytes as recorded.

Copy code

    lrs_create_socket("socket1", "TCP", "RemoteHost=199.203.77.246:21", LrsLastArg);
    lrs_set_receive_option(EndMarker, RecordingSize);
    lrs_receive("socket1", "buf2", LrsLastArg);

Suppose that the buffer during recording (buf2) was 20 bytes long, and the buffer sent by the server during replay was 30 bytes long. This example script would make the received buffer 20 bytes long. The remaining buffer data (10 bytes) will be received in the next lrs_receive call.

If the option value was EndMarker_None, then the lrs_receive call would receive the entire buffer, with a mismatch message.

### Example 3

In the following example, the lrs_set_receive_option function uses a binary string terminator.

Copy code

    lrs_create_socket("socket1", "TCP", "RemoteHost=199.203.77.246:21", LrsLastArg);
    lrs_set_receive_option(EndMarker, BinaryStringTerminator, "\\x00\\x07ABC");
    lrs_receive("socket1", "buf2", LrsLastArg);

Suppose that the buffer that the server sent contains the following:

"\x00\x01\x85\x80\x00\x01\x00\x01\x00\x00\x00\x00\x07"
"ABC"
"\x02"
"co
"\x02"
"il"
"\x00\x00\x01\x00\x01\xc0"

The received buffer, buf2, will be:

"\x00\x01\x85\x80\x00\x01\x00\x01\x00\x00\x00\x00\x07"
"ABC"

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