Module Server

module Server: sig  end
Server functions for non-blocking http servers. Features:

val system_inactive : unit -> bool
This is a flag that is set when no activity has happened since the last time this was checked
val system_sleep : int -> unit
Let the system sleep this number of microseconds
val system_set_user : string -> unit
Change the effective user ID
val system_stop : unit -> unit
Give the server some time to finish the currently started connections and then close it down
val system_stopped : unit -> bool
Check if the server is in a stopping state
val system_add_safe : string -> string -> unit
system_add_safe set directory Add a directory to the list of directories (including their sub directories) where static content of the website is searched.

The first added directory acts like the root directory of the static content of the server.

val system_check_safe : string -> string -> bool
system_check_safe set file Symbolic links are checked and when the resulting file is inside one of the save directories this function returns true
val set_server_parm : string -> string -> unit
set_server_parm var value Set an internal server variable, these are readable by all the client scripts

special values:

"status" of HTTP-response

"challenge" set the WWW-autorization-challenge of the HTTP-response
val socket_create : int -> int -> int
Create a normal socket with port_nr max_connections resulting in the socket
val socket_loop : unit -> bool
Loop through all the currently open sockets, returns false after the last one
val socket_create_ssl : int -> int -> string -> string -> string -> int
Create a secure socket with port_nr max_connections certificate_file privatekey_file certificate_password resulting in the socket
val socket_listen : unit -> unit
Listen on a socket for new connections and register the new connections
val socket_close : int -> unit
Close a socket
val socket_current : unit -> int
Returns the number of the current socket inside a socket loop or after defining a socket
val conn_loop : unit -> bool
Loop through all the current connections on all sockets
val conn_header : int -> int -> int
Try to read the header on the current connection with keep_alive time to wait for new headers on the current connections and a timeout that stops reading after this amount of inactivity both the parameters are in milliseconds.

The functions returns 1 after completion of the header or 2 to close the current connection (error or keep_alive exceeded). On a 0 the rest of the connections should be checked and then this connection should be checked again for completion.

val conn_send : int -> unit
This function try's to send data on a connections. The functions 'conn_file' and 'conn_calc' can provide data to send. The parameter is timeout and it stops sending after the time in milliseconds of inactivity.
val conn_var : string -> string -> string
Get information out of the current client request type name can be:
val conn_var_list : string -> string -> string
Get variable contents. Possibly multiple instances when called multiple times, raises exception End_of_file when no more values.
val conn_var_loop : string -> string
Get all the variable names of a specific type of variable. After the last variable this function raises the End_of_file exception.
val conn_cookie : string -> string -> int -> unit
Set a cookie for the current page conn_set_cookie name value days
val conn_calc : (string -> string -> Html.t list) -> string -> string -> bool
Calculates a dynamic page and stores the result into the data to be send away. The parameter docalc is a function that should provide the calculation itself and results into html data. The other parameters tp and name are given to docalc as a tuple to find the correct dynamic page to calculate. The first parameter to docalc contains all the information that can be gathered by the 'conn_var' function.
val conn_close : unit -> unit
Close a connection
val conn_file : string -> string -> int -> bool
conn_file set filename expires -> will_be_send? Send a total file over the connection. This function tries to determine the mime-type of this file. The expires is counted in days from now, this can be zero to check the cache date every time.
val conn_parms : unit -> string
Dumps the current set of variables gained form the client