The READ.SOCKET() function reads data from a socket.
READ.SOCKET(skt, max.len, flags, timeout)
If neither blocking flag is given, the blocking mode set when the socket was opened is used.
The READ.SOCKET() function returns data read from the specified socket. The STATUS() function returns zero if the action is successful, or a non-zero error code if an error occurs. A timeout will return an error code of ER$TIMEOUT as defined in the SYSCOM ERR.H record.
SRVR.SKT = CREATE.SERVER.SOCKET("", 0)
IF STATUS() THEN STOP 'Cannot initialise server socket'
SKT = ACCEPT.SOCKET.CONNECTION(SRVR.SKT, 0)
IF STATUS() THEN STOP 'Error accepting connection'
DATA = READ.SOCKET(SKT, 100, SKT$BLOCKING, 0)
This program fragment creates a server socket, waits for an incoming connection, reads a single data packet of up to 100 bytes from this connection and then closes the sockets. The timeout value of 0 in the READ.SOCKET() call specifies that no timeout is to be used.