Ocamlnet 3 Reference Manual : Uq_engines.input_engine

# Class Uq_engines.input_engine

    class ['a] input_engine : (Unix.file_descr -> 'a) -> Unix.file_descr -> float -> Unixqueue.event_system -> ['a] engine

Generic input engine for reading from a file descriptor: `let e = new input_engine f fd tmo` - Waits until the file descriptor becomes readable, and calls then `let x = f fd` to read from the descriptor. The result `x` is the result of the engine.

If the file descriptor does not become readable within `tmo` seconds, the resulting engine transitions to ``Error Timeout`.

Use this class to construct engines reading via `Unix.read` or comparable I/O functions:

          let read_engine fd tmo esys =
            new input_engine (fun fd ->
                                let buf = String.create 4096 in
                                let n = Unix.read fd buf 0 (String.length buf) in
                                String.sub buf 0 n
                             )
                             fd tmo esys

This engine returns the read data as string.

See also `Uq_io.input_e` for a more generic way of reading with engines.