ReceiveAsynchronous (Socket function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 10: Line 10:
<td>A variable or an expression that is a reference to a <var>Socket</var> object.</td></tr>
<td>A variable or an expression that is a reference to a <var>Socket</var> object.</td></tr>
<tr><th><var>Target</var></th>
<tr><th><var>Target</var></th>
<td>string</td></tr>
<td>This [[Notation conventions for methods#Named parameters|name allowed]] parameter is a %variable or an <var>IMAGE</var> 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 <var class="term">%BytesReceived</var> value.
</td></tr>
 
<tr><th><var>MaxBytes</var></th>
<tr><th><var>MaxBytes</var></th>
<td>number</td></tr>
<td>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 <var class="term">maxrecvp</var> is 0 and <var class="term">target</var> is a <var>Longstring</var>, the received data is limited to 2,147,483,647 bytes. The <var>MaxBytes</var> argument value must not exceed 2,147,483,647.
<var>MaxBytes</var> may have the special value <code>-1</code> to indicate there is no limit to the number of bytes received.
</td></tr>
 
<tr><th><var>Options</var></th>
<tr><th><var>Options</var></th>
<td>string</td></tr>
<td>This optional, name allowed, parameter is an option string, which can contain either of the following:
<table class="syntaxTable">
<tr><th><var>BINARY</var></th>
<td>Regardless of the socket's <var>[[BINARY (JANUS DEFINE parameter)|BINARY]]</var> or <var>[[CHAR (JANUS DEFINE parameter)|CHAR]]</var> port parameter, data '''is not translated''' when saved in the receive target. The received string can be translated later in the program using the <var>[[TranIn (Socket function)|TranIn]]</var> method. </td></tr>
<tr><th><var>CHAR</var> </th><td>Regardless of the socket's <var>BINARY</var> or <var>CHAR</var> parameter, data '''is translated''' when saved in the receive target. The translation is specified by the input table defined by the socket's <var>[[XTAB (JANUS DEFINE parameter)|XTAB]]</var> port parameter.
</td></tr>
<tr><th>PRSTOK [AMBIG|]<i>hexstr</i>[|<i>hexstr</i>]...
</th><td>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 <var>[[Set (Socket function)|Set]]</var> or <var>ReceiveAndParse</var> methods, <var>PRSTOK</var> must '''not''' be <code>NONE</code> or <var>ReceiveAndParse</var> will fail.
</td></tr></table>
 
<tr><th><var>Wait</var></th>
<tr><th><var>Wait</var></th>
<td><var>Boolean</var> value</td></tr>
<td><var>Boolean</var> 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.                                         
</td></tr>
</table>
</table>



Revision as of 20:09, 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