Example: lrs_get_last_received_buffer

In the following example, the lrs_get_last_received_buffer function gets the last buffer and its size that were received on socket2.

char *ActualBuffer;
int NumberOfBytes;
lrs_receive("socket2", "buf20", LrsLastArg); 
/* Get the last received buffer and its size. */
lrs_get_last_received_buffer("socket2", &ActualBuffer, &NumberOfBytes);
lr_output_message("The last buffer's size is:%d/n, NumberOfBytes);
The contents of the buffer, as shown in the data file data.ws are:
Recv buf3 9
    "\xff\xfb\x01abc\n"
The output generated by the above code, as seen in the VuGen Execution log is:
Message from run.c(32): The buffer size is: 7 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:
lrs_save_param_ex("socket2", "user", ActualBuffer, 3, 3, "ascii", "new_parameter");
lrs_free_buffer(ActualBuffer);
lr_output_message("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): new_parameter = "abc"