Share this page

# lrs_get_received_buffer

Buffer Functions

Gets the last received buffer or a part of it.

    char *lrs_get_received_buffer( char *s_desc, int offset, int length, char *encoding );

s_desc | A descriptor identifying a socket.
offset | The offset inside a buffer (binary representation of the data).
length | The length of the data to retrieve (binary representation). Specify -1 to ignore the offset and retrieve the whole buffer.
encoding | The encoding method for the returned data. The possible values are "ascii", "ebcdic", or NULL

The lrs_get_received_buffer function retrieves the whole buffer or part of it, that was received from the last call to either lrs_receive, lrs_receive_ex or lrs_length_receive. You specify the offset and length of the data to retrieve.

After this function is executed, the retrieved buffer (or part of the buffer) is stored in the internal buffer (User Buffer ) in the format specified by the encoding parameter. The return value is a pointer to the user buffer. If the encoding parameter is set to NULL, the user buffer is stored in the original client encoding (either ebcdic or ascii).

To retrieve the contents of the user buffer, use lrs_get_user_buffer . To determine its size, use lrs_get_user_buffer_size.

Note that the following functions overwrite the same internal buffer (user buffer):

- lrs_ascii_to_ebcdic

- lrs_ebcdic_to_ascii

- lrs_get_received_buffer

- lrs_get_static_buffer

- lrs_decimal_to_hex_string

In all of the above user buffer functions (except lrs_decimal_to_hex_string), use lrs_get_user_buffer_size to determine the actual buffer size before printing the buffer contents. Do not retrieve the entire buffer using a -1 as the length argument, and then try to print its contents. The reason for this is that VuGen may misinterpret the NULL characters within the buffer as a terminating string. Print functions include all the Message Functions such as lr_output_message.

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.

## Example

    In the following example, lrs_get_received_buffer gets the last buffer received on "socket2", "\xff\xffUser=TNT\r\n". It retrieves three bytes of data at an offset of 7, which is the User Name.

    char *ReceivedBuffer;

    ReceivedBuffer = lrs_get_received_buffer("socket2", 7, 3, NULL);

    /* The value in ReceivedBuffer is now "TNT" */

    To save the contents of a buffer to a parameter for later use, type:

    lrs_save_param_ex("socket2", "user", ReceivedBuffer, 0, 3, "ascii", "new_parameter");

    lr_output_message("The new parameter = \"%s\"\n", lr_eval_string("< new_parameter >"));

The output generated by the above code, as seen in the VuGen Execution log is:
Message from run.c(52): The new parameter = "TNT"

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: