Skip to main content
Version: v4 (Stable)

RECEIVEFROM

RECEIVEFROM(message AS STRING BYREF, origin AS STRING BYREF [, timeout AS INTEGER[, port AS STRING BYREF[, coding As INTEGER]]]) AS INTEGER

Waits for reception of a message during the maximum time of <timeout> milliseconds. Specify the waited message coding in the optional parameter <coding>: 0=ANSI (default value), 1=UNICODE, 2=Binary, 3=UTF8.

If the optional parameter <timeout> is null (default value), the function returns the current received message without waiting. If <timeout> is equal to -1, the function waits for the message without time limitation.

If a message is received, the function copies the message in the variable <message> and the sender address in the variable <origin>.

In the case of IP scripts, the parameter <port>, when defined, returns the number of the sender IP port. If the parameter <port> is not defined, the port number is returned after the sender address in the parameter <origin> (format <ip address>:<port>).

The function returns the length of the received message (if a message is received), 0 if the timeout is expired, -1 if the communication is aborted.

For IP connections, the function returns -2 when the socket is disconnected and the script continues to run.