package mirage-types
Type of a buffered byte-stream that is attached to an unbuffered flow (e.g. a TCPv4 connection).
create flow
will allocate send and receive buffers and associated them with the given unbuffered flow
.
Read a single character from the channel, blocking if there is no immediately available input data.
read_until t ch
will read from the channel until the given ch
character is found. It returns a tuple indicating whether the character was found at all (false
indicates that an EOF condition occurred before the character was encountered), and the buffer
pointing to the position immediately after the character (or the complete scanned buffer if the character was never encountered).
read_stream ?len t
will return up to len
characters as a stream of buffers. This call will probably be removed in a future revision of the API in favour of read_some
.
read_line t
will read a line of input, which is terminated either by a CRLF sequence, or the end of the channel (which counts as a line).
val write_char : t -> char -> unit
write_char t ch
writes a single character to the output channel.
val write_string : t -> string -> int -> int -> unit
write_string t buf off len
writes len
bytes from a string buf
, starting from from offset off
.
write_buffer t buf
will copy the buffer to the channel's output buffer. The buffer should not be modified after being written, and it will be recycled into the buffer allocation pool at some future point.
val write_line : t -> string -> unit
write_line t buf
will write the string buf
to the output channel and append a newline character afterwards.
flush t
will flush the output buffer and block if necessary until it is all written out to the flow.