Module Lwt_io

module Lwt_io : sig..end

Buffered byte channels

A channel is a high-level object for performing IOs. It allow to read/write things from/to the outside worlds in an efficient way, by minimising the number of system calls.

An output channel is a channel that can be used to send data and an input channel is a channel that can used to receive data.

If you are familiar with buffered channels you may be familiar too with the flush operation. Note that byte channles of this modules are automatically flushed when there is nothing else to do (i.e. before the program goes into idle), so this means that you no longer have to write:

eprintf "log message\n";
      flush stderr;

to have you messages displayed.

Note about errors: input functions of this module raise End_of_file when the end-of-file is reached (i.e. when the read function returns 0). Other exceptions are ones caused by the backend read/write functions, such as Unix.Unix_error.

exception Channel_closed of string

Exception raised when a channel is closed. The parameter is a description of the channel.

type 'a channel

Type of buffered byte channels

type input

Input mode

type output

Output mode

type 'a mode = private  | Input | Output

Channel mode

val input : input mode

input input mode representation

val output : output mode

output output mode representation

type input_channel = input channel

Type of input channels

type output_channel = output channel

Type of output channels

val mode : 'a channel -> 'a mode

mode ch returns the mode of a channel

Well-known instances
val stdin : input_channel

The standard input, it reads data from Lwt_unix.​stdin

val stdout : output_channel

The standard output, it writes data to Lwt_unix.​stdout

val stderr : output_channel

The standard output for error messages, it writes data to Lwt_unix.​stderr