FCGI::Async - Module to allow use of FastCGI asynchronously
This module allows a program to respond to FastCGI requests using an asynchronous model. It is based on IO::Async and will fully interact with any program using this base.
use FCGI::Async; use IO::Async::Set::IO_Poll; my $fcgi = FCGI::Async->new( on_request => sub { my ( $fcgi, $req ) = @_; # Handle the request here } ); my $set = IO::Async::Set::IO_Poll->new(); $set->add( $fcgi ); $set->loop_forever;
This function returns a new instance of a FCGI::Async object, containing a master socket to listen on. The constructor returns immediately; it does not make any blocking calls.
FCGI::Async
The function operates in one of three ways, depending on arguments passed in the %args hash:
%args
Listening on an existing socket.
socket => $socket
This must be a socket opened in listening mode, derived from IO::Socket, or any other class that handles the fileno and accept methods in a similar way.
IO::Socket
fileno
accept
Creating a new listening socket.
port => $port
A new IO::Socket::INET socket will be opened on the given port number. It will listen on all interfaces, from all addresses.
IO::Socket::INET
Using the socket passed as STDIN from a webserver.
When running a local FastCGI responder, the webserver will create a new INET socket connected to the script's STDIN file handle. To use the socket in this case, pass neither of the above options.
The %args hash must also contain a CODE reference to a callback function to call when a new FastCGI request arrives
on_request => sub { ... }
or
on_request => \&handler
This will be passed two parameters; the FCGI::Async container object, and a new FCGI::Async::Request object representing the specific request.
FCGI::Async::Request
$on_request->( $fcgi, $request )
CGI::Fast - Fast CGI drop-in replacement of CGI; single-threaded, blocking mode.
http://hoohoo.ncsa.uiuc.edu/cgi/interface.html - The Common Gateway Interface Specification
http://www.fastcgi.com/devkit/doc/fcgi-spec.html - FastCGI Specification
Paul Evans <leonerd@leonerd.org.uk>
2 POD Errors
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
=back without =over
To install FCGI::Async, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FCGI::Async
CPAN shell
perl -MCPAN -e shell install FCGI::Async
For more information on module installation, please visit the detailed CPAN module installation guide.