webSocketRead()

Tries to retrieve the next message form the WebSocket.

Synopsis

int webSocketRead(int socket, anytype|string|blob &data [, time maxTimeout])

Parameters

Parameter Description
socket The socket number returned by webSocketOpen().
data Variable in which the read data is stored.
maxtimeout

The maximum timeout. It determines how long the function waits for the message.

This timeout is unlimited if no value is given.

Return value

On successful retrieval of a message 0 is returned. If the socket is closed, 1 is returned. On error -1 is returned. On timeout -2 is returned.

Errors

Errors can be network errors, for which getLastError() can be used to get a more detailed error message.

Description

Tries to retrieve the next message from the WebSocket and stores it in the given "data" argument. When no message was received yet, it waits until the given maxTimeout.

Assignment

WebSocket functions

Availability

CTRL