Plasma GitLab Archive
Projects Blog Knowledge

Class type Uq_engines.server_socket_acceptor


class type server_socket_acceptor = object .. end
This class type is for service providers that listen for connections. By calling accept, one gets an engine that waits for the next connection, and establishes it.

There are services that can only accept one connection for a certain contact address. In this case accept must only be called once. Normally, services can accept any number of connections (multiplexing), and it is allowed to call accept again after the previous accept engine was successful.


method server_address : sockspec
The contact address under which the clients can establish new connections with this server.
method multiple_connections : bool
Whether it is possible to accept multiple connections
method accept : unit -> (Unix.file_descr * sockspec) engine
Instantiates an engine that accepts connections on the listening socket.

If the connection is successfully established, the state of the engine changes to `Done(fd,addr) where fd is the connected file descriptor, and where addr is the socket address of the connecting client (from the server's perspective).

The close-on-exec flag of the created socket descriptor is always set. The socket descriptor is always in non-blocking mode.

It is allowed to shut down fd for sending, and it is required to close fd after all data transfers have been performed.

A call of accept allows it only to establish one connection at a time. However, it is allowed to call accept several times to accept several connections, provided the acceptor supports this (returned by multiple_connections). It is only allowed to call accept again when the previous engine was successful.

method shut_down : unit -> unit
The server socket is shut down such that no further connections are possible. It is required to call this method even for acceptors that do not support multiple connections. It is also required to call this method when an accept was not successful.

If there is a engine waiting for connections, it is aborted.

This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml