8 recv% function – Rockwell Automation 57C610 Enhanced Basic Language, AutoMax User Manual
Page 117
8Ć7
8.8
RECV% Function
Format:
RECV%( sn%, var, len% )
where:
sn%
is the number of the socket through which the
message is to be received. This is the value that
was returned from the SOCKET% or ACCEPT%
function. This can be specified as a simple variable
or as an element of an array.
var
is the variable where the data received is written. It
can be a boolean, integer, double integer, real,
string, or an array of those types. If an array is
specified, no subscript may be given.
len%
is the number of bytes to receive. This parameter
can be a constant, an integer, or a double integer.
If var is a simple variable and len% is greater than
the size of the simple variable, then var must be
defined as I/O to avoid overwriting AutoMax
memory.
If var is an array, and len% is zero, the length to
receive is the size of the array. An error is
generated if len% is greater than the size of the
array.
For TCP only, if len% is -1, the number of bytes
received will be returned to the sender.
This function writes up to len% bytes of data from socket SN% into
the variable VAR.
If a TCP socket is specified, it must be connected.
A socket can be selected as blocking or nonĆblocking. If the socket
is blocking and no data has come in, the task will be suspended
until data arrives. If the socket is nonĆblocking and no data has
come in, the RECV% command will return with the error No
message waiting. The default mode is blocking.
Values Returned:
>0
Length of message received
-2
ENI not initialized
-9
No buffer space
-15 Bad socket number
-17 Message too long
-18 Zero length for nonĆarray
-26 Array is not single dimension
-29 Max size of strings are not equal
-31 Max size of string < recv size of string
-32 Beyond end of array
-101 No message waiting
-102 Socket not connected
For example:
RECV_LEN% = RECV%( SN%, SET_POINTS%, LEN%)