http://www.perlmonks.org?node_id=899187

petr999 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Friends,

I observe the difference in FCGI.pm usage.

When $f in the code is INET the client asks server and exits fine. Client code:

use FCGI; use IO::Socket; my $f = 'INET'; my @tcp = ( '127.0.0.1', '8888' ); my $lsock = "/tmp/spawn.sck"; my $s; if( $f eq 'UNIX' ){ ( -S $lsock ) and ( unlink( $lsock ) or die $! ); $s = FCGI::OpenSocket( $lsock, 5 ); } else { $s = FCGI::OpenSocket( join( ':', @tcp ), 5 ); } $s or die $!; my $r = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%ENV, $s ); while($r->Accept() >= 0) { print "Content-type: text/html\r\n\r\n"; }

Server code:

use IO::Socket; use FCGI::Client; my $f = 'INET'; my @tcp = ( '127.0.0.1', '8888' ); my $lsock = "/tmp/spawn.sck"; my $s = $f eq 'UNIX' ? IO::Socket::UNIX->new( "PeerAddr" => $lsock, "Type" => SOCK_STREAM +, Timeout => 3, ) : IO::Socket::INET->new( "PeerAddr" => $tcp[ 0 ], "PeerPort" => $tc +p[ 1 ], "Type" => SOCK_STREAM, Timeout => 3, ) ; $s or die $!; my $c = FCGI::Client::Connection -> new( sock => $s, timeout => 3, ); $c -> request( +{ REQUEST_METHOD => "GET", }, "" ); $s -> close;
But when $f is UNIX, it exits while trying to read from FCGI socket:
REQUEST_TIME_OUT at [.]/FCGI/Client/Connection.pm line 25 FCGI::Client::Connection::__ANON__('ALRM') called at [..]/FCGI +/Client/Connection.pm line 92 eval {...} called at [..]/FCGI/Client/Connection.pm line 92 FCGI::Client::Connection::_wait_socket('FCGI::Client::Connecti +on=HASH(0x28983aa0)', 'IO::Socket::UNIX=GLOB(0x2875d0ac)', undef, 130 +2700410.97483) called at [..]/FCGI/Client/Connection.pm line 113 FCGI::Client::Connection::_read_timeout('FCGI::Client::Connect +ion=HASH(0x28983aa0)', 'SCALAR(0x289eef84)', 8, 0) called at [..]/FCG +I/Client/Connection.pm line 63 FCGI::Client::Connection::_read_record('FCGI::Client::Connecti +on=HASH(0x28983aa0)', 'FCGI::Client::Connection=HASH(0x28983aa0)') ca +lled at [..]/FCGI/Client/Connection.pm line 37 FCGI::Client::Connection::_receive_response('FCGI::Client::Con +nection=HASH(0x28983aa0)', 'IO::Socket::UNIX=GLOB(0x2875d0ac)') calle +d at [..]/FCGI/Client/Connection.pm line 28 FCGI::Client::Connection::request('FCGI::Client::Connection=HA +SH(0x28983aa0)', 'HASH(0x28796110)', '') called at client00.pl line 1 +8

What can influence on that behavior? system is freebsd7.

Do I need to send a terminator character/sequence to end my FCGI request?

Or what should I do next? Make FCGI request manually and send it? I believe I can do with Net::FastCGI but I need to look at fastcgi spec for this...

Should this be a FCGI::Client bug?

Thank you.