read text data from a socket connection
valid open socket ID
(optional) non-negative integer; specify a timeout in seconds
The procedure Read is used to read textual data in the form of Maple strings from a socket connection.
The argument sid must be a valid socket ID for an open socket connection. An optional timeout argument can be passed, which is taken to be the number of seconds to wait before timing out the read operation.
When called, Read blocks indefinitely until data becomes available on the socket sid at which time the available data (up to a system dependent maximum number of bytes) is read. Data read from the socket is returned as a Maple string. If called with the timeout parameter and no data becomes available on the socket sid within the specified number of seconds, then the Read operation returns false.
Calls of the form Read( sid, 0 ) immediately return the value false.
Because Maple strings cannot contain null bytes, Read should be used only when you are sure that the data coming in over the network consists of plain ASCII text. (This is frequently the case.) If data may contain null bytes, then you should use Sockets[ReadBinary] instead.
The Read procedure obeys the persistent timeout protocol. (See Sockets/timeout.)
This example illustrates how data may appear to be lost if it contains null bytes.
The underlying problem is that Maple strings cannot contain null bytes.
Download Help Document
What kind of issue would you like to report? (Optional)