# Module Uq_server

    module Uq_server: sig .. end

## Server sockets

    type listen_address = [ `Socket of Uq_engines.sockspec * listen_options
           | `W32_pipe of Netsys_win32.pipe_mode * string * listen_options ]

Specifies the resource to listen on:

- ``Socket(addr,opts)`: It is listened on a socket with address `addr`
- ``W32_pipe(mode,name,opts)`: It is listened on a pipe server with `name` which accepts pipe connections in `mode`.

    type listen_options = Uq_engines.listen_options = {

`` | `lstn_backlog : `int`;` | `(*` | The length of the queue of not yet accepted connections. | `*)`
`` | `lstn_reuseaddr : `bool`;` | `(*` | Whether to allow that the address can be immediately reused after the previous listener has its socket shut down. (Only for Internet sockets.) | `*)`

}

    val default_listen_options : listen_options

Returns the default options

    val listen_on_inet_socket : Unix.inet_addr ->
           int -> Unix.socket_type -> listen_options -> Unix.file_descr

`listen_on_inet_socket addr port stype opts`: Creates a TCP or UDP server socket for IPv4 or IPv6, depending on the type of address. The socket is listening.

As special cases, the addresses "::1" and "::" are always understood even if IPv6 is not avaiable, and treated as the corresponding IPv4 addresses (127.0.0.1 and 0.0.0.0, resp.) instead.

    val listen_on_unix_socket : string -> Unix.socket_type -> listen_options -> Unix.file_descr

`listen_on_unix_socket path stype opts`: Creates a Unix Domain server socket for the given `path`. The socket is listening.

On Win32, Unix Domain sockets are emulated by opening an Internet socket on the loopback interface, and by writing the port number to `path`.

    val listen_on_w32_pipe : Netsys_win32.pipe_mode ->
           string -> listen_options -> Unix.file_descr

`listen_on_w32_pipe mode path opts`: Creates a Win32 pipe server and returns the proxy descriptor.

    val listen_on : listen_address -> Unix.file_descr

`listen_on addr`: Creates a server endpoint for `addr`

    class type server_endpoint_acceptor = object .. end

This class type is for service providers that listen for connections.

    class direct_acceptor : ?close_on_shutdown:bool -> ?preclose:unit -> unit -> Unix.file_descr -> Unixqueue.event_system -> server_endpoint_acceptor

An implementation of `server_endpoint_acceptor` for sockets and Win32 named pipes.

    val listener : ?proxy:#Uq_engines.server_endpoint_listener ->
           listen_address ->
           Unixqueue.event_system ->
           server_endpoint_acceptor Uq_engines.engine

This engine creates a server socket listening on the `listen_address`. If passed, the `proxy` is used to create the server socket.

On success, the engine goes to state ``Done acc`, where `acc` is the acceptor object (see above). The acceptor object can be used to accept incoming connections.