Share this page

# lrs_get_buffer_by_name

Buffer Functions

Gets a buffer and its size for the specified buffer descriptor.

    int lrs_get_buffer_by_name( char *buf_desc, char **data, int *size );

Input |
buf_desc | A descriptor identifying a buffer.
Output |
data | A pointer to the buffer containing the data.
size | A pointer to the size (in bytes) of the data.

The lrs_get_buffer_by_name function gets a binary buffer and the length of the binary representation of the data for the specified the buffer descriptor. Note that the data buffer is not NULL terminated.

This function is not recorded during a WinSock session—you manually insert it into your script. In addition, you must declare variables to store the buffer and its size, before calling lrs_get_buffer_by_name. Declare a character pointer for the data parameter, and an integer for the size parameter. Note that the memory for the buffer is allocated automatically, but you must free the memory after you use this function using lrs_free_buffer .

## 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_buffer_by_name gets the buffer and its size for the buffer descriptor "buff2".

    char *ActualBuffer;

    int NumberOfBytes;

    lrs_get_buffer_by_name("buff2", &ActualBuffer, &NumberOfBytes);

    lr_output_message("The buffer's size is: %d/n", NumberOfBytes);

    The contents of the buffer, as shown in the data file data.ws are:

    recv buff2 3
        "\xff\xfe\x01"

The output generated by the above code, as seen in the VuGen Execution log is:
Message from run.c(52): The buffer size is: 3 bytes
The ActualBuffer variable is a pointer to binary data; therefore you should not use string functions to manipulate it. To save the content of the buffer to a parameter for later use:
/* Save the contents of ActualBuffer into a parameter called "new_parameter" */
lrs_save_param_ex("socket2", "user", ActualBuffer, 0, NumberOfBytes, "ascii", "new_parameter");
lrs_free_buffer(ActualBuffer);
lr_output_message("The buffer contains \"%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 buffer contains: "\xff\xfe\n"

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: