# Module Netcgi_scgi

    module Netcgi_scgi: sig .. end

SCGI connector.

The SCGI connects your web applications through a TCP/IP socket (thus the application can run on a machine different from the web server).

See the Setup section at the end of this file to know how to configure your web server.

    val run : ?config:Netcgi.config ->
           ?allow:(Unix.sockaddr -> bool) ->
           ?output_type:Netcgi.output_type ->
           ?arg_store:Netcgi.arg_store ->
           ?exn_handler:Netcgi.exn_handler ->
           ?socket:Unix.file_descr ->
           ?sockaddr:Unix.sockaddr -> ?port:int -> (Netcgi.cgi -> unit) -> unit

`run f` executes `f cgi` for each SCGI request.
`config` : Default: `Netcgi.default_config`
`allow` : Tells whether a connection from the socket is allowed. Default: allow from all.
`output_type` : Default: ``Direct ""`
`arg_store` : Default: ``Automatic` for all arguments.
`exn_handler` : See `Netcgi.exn_handler`. Default: delegate all exceptions to the default handler.
`socket` : is a listening socket to use. Overrides `sockaddr` and `port`
`sockaddr` : The sockaddr for listening. Overrides `port`
`port` : The port for listening. Needs to be specified if no `sockaddr` is passed.

    val handle_request : Netcgi.config ->
           Netcgi.output_type ->
           Netcgi.arg_store ->
           Netcgi.exn_handler ->
           (Netcgi.cgi -> unit) ->
           log:(string -> unit) option -> Unix.file_descr -> Netcgi.connection_directive

`handle_request config output_type arg_store eh f ~log fd`: This is a lower-level interface that processes exactly one request arriving on the existing connection `fd`.

`log` is the error logger function or `None`, in which case errors are passed through to the FCGI client.

The other arguments are just like for `run`.

The return value indicates whether the connection can be kept open or must be closed.

    val handle_connection : Netcgi.config ->
           Netcgi.output_type ->
           Netcgi.arg_store ->
           Netcgi.exn_handler -> (Netcgi.cgi -> unit) -> Unix.file_descr -> unit

`handle_connection config output_type arg_store eh f ?script_name fd`: This is a lower-level interface that processes exactly one connection `fd`. The descriptor is closed (even on error).

The other arguments are just like for `run`.

## Setup

Add to httpd.conf or to, say, scgi.conf in /etc/apache/conf.d

        LoadModule scgi_module /usr/lib/apache/1.3/mod_scgi.so
        # Serve the URL /scgi by contacting 127.0.0.1 on port 8888
        SCGIMount /scgi 127.0.0.1:8888