blockingOperation: if true and the calling script is running in a thread, then the function only returns when the desired data length was read (or if the closingString was met, or if there was a timeout (see next arguments)

closingString: a string (containing any byte value) can be specified, that will break from the blocking operation if a match was found in the incoming data. Useful when you know that a data packet is always ended with a given signature. Can be an empty string for default operation.

timeout: duration after which the blocking operation will be aborted, or 0 if the timeout is infinite.

Lua return values

data: a string containing read data (excluding the closingString if it was specified and found)