Library
Module
Module type
Parameter
Class
Class type
Functor to create a CHANNEL from a V1_LWT.FLOW
implementation
module F : V1_LWT.FLOW
include V1_LWT.CHANNEL with type flow = F.flow
type buffer = Cstruct.t
The type for memory buffers.
type flow = F.flow
The type for unbuffered network flow.
type 'a io = 'a Lwt.t
The type for potentially blocking I/O operation
type 'a io_stream = 'a Lwt_stream.t
The type for potentially blocking stream of IO requests.
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_some ?len t
will read up to len
characters from the input channel and at most a full buffer
. If len
is not specified, it will read all available data and return that buffer.
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.
exception Read_error of F.error
exception Write_error of F.error