Example: lrs_receive_exSockets Functions

Receives data of a specified length from a datagram or stream socket.

int lrs_receive_ex( char *s_desc, char *bufindex, [char *flags,] [char *size,]     [char *terminator,] [char *mismatch,] [char *RecordingSize,]    LrsLastArg );
s_desc A descriptor identifying a connected socket.

A descriptor identifying a buffer.

For details on editing the Windows Sockets Buffers, see How to View and Modify Windows Sockets Buffers under Windows Sockets Protocol in the VuGen User Guide.

flagsReceive and Send Flags that specify various ways which the call can be made (optional). Use the following format:"Flags=flags"
size The number of bytes to receive in the following format:"NumberOfBytesToRecv=xx" (only available for TCP sockets).
terminator The character(s) marking the end of the block to receive, in the format:"StringTerminator= value " or "BinaryStringTerminator= value " (only available for TCP sockets).
mismatch The criterion for a mismatch—size or content. Use the following format: "Mismatch= value " where value can be either MISMATCH_SIZE (default) or MISMATCH_CONTENT.
RecordingSize The size of the buffer received during recording(only available for TCP sockets). Use the following format: "RecordingSize"
LrsLastArg A marker indicating the end of the parameters (used where optional parameters are available).

The lrs_receive_ex function reads a specified number of bytes from the incoming data from a datagram or stream socket. It is equivalent to the lrs_receive function, except for the ability to specify the number of bytes to receive.

VuGen determines the expected size of the buffer from the recorded session. If the buffer size does not match (smaller or larger), lrs_receive_ex rereads the incoming data carried by the socket, until the receive_timeout. By default the receive_timeout is 10 seconds. You can modify the timeout using lrs_set_recv_timeout.

Note that the successful completion of a lrs_receive_ex does not indicate that all of the data was successfully received. If the received buffer does not match the expected buffer, VuGen sends a message to the output indicating the mismatch and continues with script execution.

If the socket's type is TCP and the remote side has shut down the connection in an orderly way, lrs_receive_ex finishes without returning any data. If the connection was aborted, lrs_receive_ex returns one of the Windows Sockets error codes.

If you do not specify a size or terminating string, lrs_receive_ex receives all of the data in the block.

This function is not recorded by VuGen—you must insert it into your script manually. You can replace the recorded function, lrs_receive function, with this function in your script.

Return Values

Windows Sockets Return Values


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