# Module Uq_transfer

    module Uq_transfer: sig .. end

## Transfer engines

Transfer engines copy data between file descriptors. This kind of engine is likely to be declared as deprecated in the future. If possible, one should use multiplex controllers (see below), and for copying streams the generic copier `Uq_io.copy_e` is a better choice.

The pure types `async_in_channel` and `async_out_channel` have been proven to be useful for bridging with `Netchannels`.

    class type async_out_channel = object .. end

An asynchrounous output channel provides methods to output data to a stream descriptor.

    class type async_in_channel = object .. end

An asynchrounous input channel provides methods to input data from a stream descriptor.

    class pseudo_async_out_channel : #Netchannels.raw_out_channel -> async_out_channel

Takes a `Netchannels.raw_out_channel` as an asynchronous channel.

    class pseudo_async_in_channel : #Netchannels.raw_in_channel -> async_in_channel

Takes a `Netchannels.raw_in_channel` as an asynchronous channel.

    class receiver : src:Unix.file_descr -> dst:#async_out_channel -> ?close_src:bool -> ?close_dst:bool -> Unixqueue.event_system -> [unit] Uq_engines.engine

This engine copies all data from the `src` file descriptor to the `dst` output channel.

    class sender : src:#async_in_channel -> dst:Unix.file_descr -> ?close_src:bool -> ?close_dst:bool -> Unixqueue.event_system -> [unit] Uq_engines.engine

This engine copies all data from the `src` input channel to the `dst` file descriptor.

    class type async_out_channel_engine = object .. end

Combination of engine + async_out_channel

    class type async_in_channel_engine = object .. end

Combination of engine + async_in_channel

    class output_async_descr : dst:Unix.file_descr -> ?buffer_size:int -> ?close_dst:bool -> Unixqueue.event_system -> async_out_channel_engine

This engine implements an `async_out_channel` for the output descriptor `dst`.

    class input_async_descr : src:Unix.file_descr -> ?buffer_size:int -> ?close_src:bool -> Unixqueue.event_system -> async_in_channel_engine

The corresponding class for asynchronous input channels.

    type copy_task = [ `Bidirectional of Unix.file_descr * Unix.file_descr
           | `Tridirectional of Unix.file_descr * Unix.file_descr * Unix.file_descr
           | `Uni_socket of Unix.file_descr * Unix.file_descr
           | `Unidirectional of Unix.file_descr * Unix.file_descr ]

Specifies the task the `copier` class has to do:

- ``Unidirectional(src,dst)`: Data from `src` are copied to `dst`. EOF of `src` causes that both descriptors are closed.
- ``Uni_socket(src,dst)`: Data from `src` are copied to `dst`. EOF of `src` causes that `dst` is shut down for sending; all descriptors remain open. It is required that `dst` is a socket.
- ``Bidirectional(bi1,bi2)`: Data from `bi1` are copied to `bi2`, and data from `bi2` are copied to `bi1`. EOF of one descriptor causes that the other descriptor is shut down for sending. When both descriptors are at EOF, both are closed. It is required that `bi1` and `bi2` are sockets.
- ``Tridirectional(bi,dst,src)`: Data from `bi` are copied to `dst`, and data from `src` are copied to `bi` (i.e. a bidirectional descriptor is split up into two unidirectional descriptors). EOF of `bi` causes that `dst` is closed. EOF of `src` causes that `bi` is shut down for sending. EOF in both directions causes that all descriptors are closed. It is required that `bi` is a socket.

    class copier : copy_task -> Unixqueue.event_system -> [unit] Uq_engines.engine

This engine copies data between file descriptors as specified by the `copy_task` argument.

    type onshutdown_out_spec = [ `Action of
               async_out_channel_engine ->
               Uq_engines.multiplex_controller -> unit Uq_engines.engine_state -> unit
           | `Ignore
           | `Initiate_shutdown ]

See class `output_async_mplex` for explanations

    type onshutdown_in_spec = [ `Action of
               async_in_channel_engine ->
               Uq_engines.multiplex_controller -> unit Uq_engines.engine_state -> unit
           | `Ignore
           | `Initiate_shutdown ]

See class `input_async_mplex` for explanations

    class output_async_mplex : ?onclose:[ `Ignore | `Write_eof ] -> ?onshutdown:onshutdown_out_spec -> ?buffer_size:int -> Uq_engines.multiplex_controller -> async_out_channel_engine

Creates an asynchronous output channel writing to the multiplex controller (see also `output_async_descr` for the corresponding class writing to a single descriptor).

    class input_async_mplex : ?onshutdown:onshutdown_in_spec -> ?buffer_size:int -> Uq_engines.multiplex_controller -> async_in_channel_engine

Creates an asynchronous input channel reading from the multiplex controller.