ReceiveAsynchronous (Socket function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 47: Line 47:


==See also==
==See also==
 
<ul>
<li><var>[[Receive (Socket function)|Receive]]</var>
<li><var>[[ReceiveAndParse (Socket function)|ReceiveAndParse]]</var>
</ul>
{{Template:Socket:ReceiveAsynchronous footer}}
{{Template:Socket:ReceiveAsynchronous footer}}

Revision as of 21:16, 8 June 2012

Receive zero or more bytes on this socket (Socket class)

[Introduced in Sirius Mods 7.9]


Syntax

%bytesReceived = socket:ReceiveAsynchronous( [Target=] string, - [[MaxBytes=] number], - [[Options=] string], - [Wait= boolean])

Syntax terms

%BytesReceivednumber
socket A variable or an expression that is a reference to a Socket object.
Target This name allowed parameter is a %variable or an IMAGE item that is the target of the receive operation. It is referred to as the "receive target." Since you may request that some bytes from the socket stream be discarded, the length of the string stored in this target may be less than the %BytesReceived value.
MaxBytes This optional, name allowed, parameter is the maximum number of bytes of data to receive, less the length of the separator string. This optional argument defaults to 0, which means limit the received data (less separator) to the declared length of the receive target.

If maxrecvp is 0 and target is a Longstring, the received data is limited to 2,147,483,647 bytes. The MaxBytes argument value must not exceed 2,147,483,647. MaxBytes may have the special value -1 to indicate there is no limit to the number of bytes received.

Options This optional, name allowed, parameter is an option string, which can contain either of the following:
BINARY Regardless of the socket's BINARY or CHAR port parameter, data is not translated when saved in the receive target. The received string can be translated later in the program using the TranIn method.
CHAR Regardless of the socket's BINARY or CHAR parameter, data is translated when saved in the receive target. The translation is specified by the input table defined by the socket's XTAB port parameter.
PRSTOK [AMBIG|]hexstr[|hexstr]... A set of parse tokens that override the current parse tokens on the socket.

Whether it is set on the port definition or by the Set or ReceiveAndParse methods, PRSTOK must not be NONE or ReceiveAndParse will fail.

Wait Boolean value

that indicates whether it should wait the timeout time before returning if MaxBytes bytes weren't immediately available. Note that if Wait=true and the request for MaxBytes times out, the conection is not closed and some number of bytes between 0 and MaxBytes-1 would be returned. If Wait=False, ReceiveAsynchronous will returned immediately with whatever number of input bytes are available.

Usage notes

Examples

See also