FCGI(3)
π FCGI(3) β Fast CGI module π
Okay bestie, welcome to the User Contributed Perl Documentation page for FCGI, section 3. This is the Fast CGI module manual, and weβre gonna read it like a group chat: all the facts stay, the vibe is immaculate. No cap. β¨
π NAME π
FCGI - Fast CGI module.
β¨ SYNOPSIS β¨
use FCGI;
my $count = 0;
my $request = FCGI::Request();
while($request->Accept() >= 0) {
print("Content-type: text/html\r\n\r\n", ++$count);
}
πΈ DESCRIPTION πΈ
Functions, bestie:
π οΈ FCGI::Request
Creates a request handle β itβs giving main character energy, and it has these optional parameters:
inputperl file handle (default:\*STDIN)outputperl file handle (default:\*STDOUT)errorperl file handle (default:\*STDERR) These filehandles will be setup to act as input/output/error on successfulAccept.environmenthash reference (default:\%ENV) β the hash will be populated with the environment.socket(default:0) β socket to communicate with the server. Can be the result of theOpenSocketfunction. For the moment, it's the file descriptor of the socket that should be passed. This may change in the future.
You should only use your own socket if your program is not started by a process manager such as mod_fastcgi (except for the FastCgiExternalServer case) or cgi-fcgi. If you use the option, you have to let your FastCGI server know which port (and possibly server) your program is listening on. See remote.pl for an example.
flags(default:FCGI::FAIL_ACCEPT_ON_INTR) β possible values:FCGI::FAIL_ACCEPT_ON_INTRβ if set,Acceptwill fail if interrupted. If itβs not set, it will just keep on waiting.
Example usage:
my $req = FCGI::Request;
or:
my %env;
my $in = new IO::Handle;
my $out = new IO::Handle;
my $err = new IO::Handle;
my $req = FCGI::Request($in, $out, $err, \%env);
π FCGI::OpenSocket(path, backlog)
Creates a socket suitable to use as an argument to Request.
pathβ pathname of socket or colon followed by local tcp port. Note that some systems take file permissions into account on Unix domain sockets, so you'll have to make sure that the server can write to the created file, by changing theumaskbefore the call and/or changing permissions and/or group of the file afterwards.backlogβ maximum length of the queue of pending connections. If a connection request arrives with the queue full the client may receive an error with an indication ofECONNREFUSED.
π¦ FCGI::CloseSocket(socket)
Close a socket opened with OpenSocket.
π $req->Accept()
Accepts a connection on $req, attaching the filehandles and populating the environment hash. Returns 0 on success. If a connection has been accepted before, the old one will be finished first.
Note that unlike with the old interface, no die and warn handlers are installed by default. This means that if you are not running an sfio enabled perl, any warn or die message will not end up in the server's log by default. It is advised you set up die and warn handlers yourself. FCGI.pm contains an example of die and warn handlers. π
π $req->Finish()
Finishes accepted connection. Also detaches filehandles.
π $req->Flush()
Flushes accepted connection.
π§ $req->Detach()
Temporarily detaches filehandles on an accepted connection.
π $req->Attach()
Re-attaches filehandles on an accepted connection.
β $req->LastCall()
Tells the library not to accept any more requests on this handle. It should be safe to call this method from signal handlers.
Note that this method is still experimental and everything about it, including its name, is subject to change. Periodt. π
π₯ $env = $req->GetEnvironment()
Returns the environment parameter passed to FCGI::Request.
π ($in, $out, $err) = $req->GetHandles()
Returns the file handle parameters passed to FCGI::Request.
π $isfcgi = $req->IsFastCGI()
Returns whether or not the program was run as a FastCGI.
π LIMITATIONS π
FCGI.pm isn't Unicode aware, only characters within the range 0x00-0xFF are supported. Attempts to output strings containing characters above 0xFF results in a exception: (F) "Wide character in %s".
Users who wants the previous (FCGI.pm <= 0.68) incorrect behavior can disable the exception by using the "bytes" pragma.
{
use bytes;
print "\x{263A}";
}
π¦ AUTHOR π¦
Sven Verdoolaege <skimo@kotnet.org>
π COPYRIGHT AND LICENCE π
This software is copyrighted (c) 1996 by by Open Market, Inc.
See the LICENSE file in this distribution for information on usage and redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
This iconic page is FCGI(3), from perl v5.42.0, dated 2025-06-13 β bye bestie! π
π¦ where this page comes from
- opensuse-leap 16.0: perl-FCGI 2.4.6-160000.2.2 Β· OML
- opensuse-leap 16.0: perl-FCGI 2.4.6-160000.2.2 Β· OML
- opensuse-leap 16.0: perl-FCGI 2.4.6-160000.2.2 Β· OML
- opensuse-leap 16.0: perl-FCGI 2.4.6-160000.2.2 Β· OML
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms