.Peekdata Method

Top  Previous  Next

Function:

For the selected socket (selection is made through sock.num) returns the string that contains the "preview" of the data from the RX buffer. The data is NOT deleted from the buffer.

Syntax:

ser.peekdata(maxinplen as word) as string

Returns:

String containing data from the RX buffer

See Also:

sock.getdata

 


Part

Description

maxinplen

Maximum amount of data to preview (word).

Details

For TCP (sock.protocol= 1- PL_SOCK_PROTOCOL_UDP) the length of returned data is limited by one of the three factors (whichever is smaller): amount of data in the RX buffer itself, capacity of the "receiving" string variable, and the limit set by the maxinplen argument. String variables can hold up to 255 bytes of data, so this method will only allow you to preview up to 255 "next" bytes from the RX buffer.

For UDP (sock.protocol= 0- PL_SOCK_PROTOCOL_UDP), additional limitations apply. The "current" UDP datagram is always deleted automatically when the on_sock_data_arrival event is exited. This means that you will "lose" this datagram from the buffer upon exiting the on_sock_data_arrival event even if your program only used sock.peekdata. Also, the amount of data returned by sock.peekdata is limited to the "next" UDP datagram waiting in the RX buffer.