Io module

wait_readable

procedure · 2 overloadsSource

Waits until read would not wait: bytes have arrived, the peer closed its end, or the connection failed (read then says which). Nothing is consumed and no buffer is needed, so a fiber can wait for a quiet connection and take its memory only when there is something to read. Ends with .TIMED_OUT or .CANCELED like any other wait, and .CLOSED if the socket is closed meanwhile.

wait_readable :: (stream: Tcp_Stream) -> Io_Error

Waits until read would not wait: bytes have arrived, the peer closed its end, or the connection failed (read then says which). Nothing is consumed and no buffer is needed, so a fiber can wait for a quiet connection and take its memory only when there is something to read. Ends with .TIMED_OUT or .CANCELED like any other wait, and .CLOSED if the socket is closed meanwhile.

Parameters

stream: Tcp_Stream

Returns

wait_readable :: (reader: Reader) -> Io_Error

Waits until a read would return at once: bytes are there, the source ended, or it failed (the read then reports which). It takes no buffer and consumes nothing, so a connection can sit idle without holding memory and allocate only when something arrives. Deadlines and cancel end it like any other wait. .UNSUPPORTED for a reader that cannot tell (a file, a pipe, a source of your own without wait_proc): can_wait_readable says beforehand.

Parameters

reader: Reader

Returns

See also