package lwt

  1. Overview
  2. Docs

Versioned variants of APIs undergoing breaking changes.

val establish_server_1 : ?fd:Lwt_unix.file_descr -> ?buffer_size:int -> ?backlog:int -> Unix.sockaddr -> ((input_channel * output_channel) -> unit) -> server

Alias for the current Lwt_io.establish_server.

  • since 2.7.0
val establish_server_2 : ?fd:Lwt_unix.file_descr -> ?buffer_size:int -> ?backlog:int -> ?no_close:bool -> Unix.sockaddr -> ((input_channel * output_channel) -> unit Lwt.t) -> server Lwt.t

establish_server_2 sockaddr f creates a server which listens for incoming connections. New connections are passed to f. When threads returned by f complete, the connections are closed automatically. To prevent automatic closing, apply establish_server_2 with ~no_close:true.

The ?fd and ?backlog arguments have the same meaning as in Lwt_io.establish_server. ?buffer_size sets the internal buffer size of the channels passed to f.

The server does not wait for each thread. It begins accepting new connections immediately.

If a thread raises an exception, it is passed to !Lwt.async_exception_hook. Likewise, if the automatic close of a connection raises an exception, it is passed to !Lwt.async_exception_hook. To robustly handle these exceptions, you should call close manually inside f, and use your own handler.

  • since 2.7.0
val shutdown_server_1 : server -> unit

Alias for the current Lwt_io.shutdown_server.

  • since 2.7.0
val shutdown_server_2 : server -> unit Lwt.t

Closes the given server's listening socket. The thread returned by this function waits for the underlying close system call to complete.

This function does not affect sockets of connections that have already been accepted by the server, i.e. those passed by establish_server to its callback f.

  • since 2.7.0

Innovation. Community. Security.