Moved examples to eg/
[catagits/fcgi2.git] / perl / eg / remote.pl
1 #!/usr/bin/perl
2 # An example of using a remote script with an Apache webserver.
3 # Run this Perl program on "otherhost" to bind port 8888 and wait
4 # for FCGI requests from the webserver.
5
6 ## Sample Apache configuration on the webserver to refer to the
7 ## remote script on "otherhost"
8 # <IFModule mod_fastcgi.c>
9 #  AddHandler fastcgi-script fcgi
10 #  FastCgiExternalServer /path-to/cgi-bin/external.fcgi -host otherhost:8888
11 # </IfModule>
12
13 # Access the URL:  http://webserver/cgi-bin/external.fcgi
14
15 # Contributed by Don Bindner <dbindner@truman.edu>
16
17 use FCGI;
18
19 my $socket = FCGI::OpenSocket( ":8888", 5 );
20 my $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR,
21     \%ENV, $socket );
22
23 my $count;
24 while( $request->Accept() >= 0 ) {
25     print "Content-type: text/html\r\n\r\n";
26     print ++$count;
27 }
28
29 FCGI::CloseSocket( $socket );