# Module Uq_multiplex

    module Uq_multiplex: sig .. end

## Multiplex Controllers

    class type multiplex_controller = object .. end

A `multiplex_controller` is a quite low-level device to abstract bidirectional socket connections.

    class type datagram_multiplex_controller = object .. end

Additional methods for unconnected datagram handling

    exception Mem_not_supported

May be raised by multiplex controller methods `start_mem_reading` and `start_mem_writing` if these methods are not supported for the kind of file descriptor

    val create_multiplex_controller_for_connected_socket : ?close_inactive_descr:bool ->
           ?preclose:(unit -> unit) ->
           ?supports_half_open_connection:bool ->
           ?timeout:float * exn ->
           Unix.file_descr ->
           Unixqueue.unix_event_system -> multiplex_controller

Creates a multiplex controller for a bidirectional socket (e.g. a TCP socket). It is essential that the socket is in connected state. This function also supports Win32 named pipes.

Note that the file descriptor is not closed when the attached engines are terminated. One can call `inactivate` manually to do that.

`close_inactive_descr`: Whether `inactivate` closes the descriptor. True by default.

`preclose`: This function is called just before the descriptor is closed.

`supports_half_open_connection`: This implementation does not know how to find out whether the socket supports half-open connections. You can simply set this boolean because of this. Defaults to `false`. You can set it to `true` for TCP connections and for Unix-domain connections with stream semantics.

`timeout`: If set to `(t, x)`, a general timeout of `t` is set. When an operation has been started, and there is no I/O activity within `t` seconds, neither by the started operation nor by another operation, the connection times out. In this case, the operation returns the exception `x`.

    val create_multiplex_controller_for_datagram_socket : ?close_inactive_descr:bool ->
           ?preclose:(unit -> unit) ->
           ?timeout:float * exn ->
           Unix.file_descr ->
           Unixqueue.unix_event_system -> datagram_multiplex_controller

Creates a multiplex controller for datagram sockets (e.g. UDP socket).

Note that the file descriptor is not closed when the attached engines are terminated. One can call `inactivate` manually to do that.

`close_inactive_descr`: Whether `inactivate` closes the descriptor. True by default.

`preclose`: This function is called just before the descriptor is closed.

`timeout`: If set to `(t, x)`, a general timeout of `t` is set. When an operation has been started, and there is no I/O activity within `t` seconds, neither by the started operation nor by another operation, the connection times out. In this case, the operation returns the exception `x`.

    val tls_multiplex_controller : ?resume:string ->
           ?on_handshake:(multiplex_controller -> unit) ->
           role:[ `Client | `Server ] ->
           peer_name:string option ->
           (module Netsys_crypto_types.TLS_CONFIG) ->
           multiplex_controller -> multiplex_controller

Creates a new multiplex controller on top of an existing controller, and configures the new controller for running the TLS protocol.

`resume`: The endpoint resumes an old session whose data are passed here. This is only possible for client endpoints.

`on_handshake`: called back when the handshake is done

    val restore_tls_multiplex_controller : ?on_handshake:(multiplex_controller -> unit) ->
           exn ->
           (module Netsys_crypto_types.TLS_CONFIG) ->
           multiplex_controller -> multiplex_controller

Like `tls_multiplex_controller`, but this function does not create a new TLS endpoint. Instead the exn value is assumed to be a stashed old endpoint.