module Make: Make a Line Printer daemon according to the configuration
The functions are splitted to offer various points where threads
can be launched.
Failure if one if the queue names contains a space.
val socket :
?port:int -> unit -> Unix.file_descr
socket ?port () creates a socket for the LPD daemon.
port : allows to specify on which port the socket
listens. By default it is the standard port for LPD i.e. 515.
val accept :
?thread:((unit -> unit) -> unit) ->
(Unix.sockaddr -> Socket.in_channel -> Socket.out_channel -> unit) -> 'a
accept ?thread socket f listen on
socket and, for each
authorized connection (see
addr inchan outchan where
addr is the address of the
connecting machine and
outchan are buffered
communication channels connected to the client.
never returns normally.
thread : tells how to run
f in a separate thread. A
typical example is to declare it as
fun f ->
ignore(Thread.create f ()) but of course one can also arrange
the reuse a thread of a pool. The default is not to create a
new thread. Do not use that function to clone the process
fork or file descriptors will leak.
val daemon :
Unix.sockaddr -> Socket.in_channel -> Socket.out_channel -> unit
deamon addr inchan outchan will read LPD queries on
and send replies on
outchan. The particular treatement each
query receives is determined by
addr is the
address of the client. This function is typically used as
accept (socket()) daemon.