.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::FastCGI::IO 3pm" .TH Net::FastCGI::IO 3pm "2021-01-08" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::FastCGI::IO \- Provides functions to read and write FastCGI messages. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& # FCGI_Header \& @values = read_header($fh); \& $header = read_header($fh); \& $result = write_header($fh, $type, $request_id, $content_length, $padding_length); \& \& # FCGI_Record \& @values = read_record($fh); \& $record = read_record($fh); \& $result = write_record($fh, $type, $request_id); \& $result = write_record($fh, $type, $request_id, $content); \& \& # FCGI_Record Stream \& $result = write_stream($fh, $type, $request_id, $content); \& $result = write_stream($fh, $type, $request_id, $content, $terminate); \& \& # I/O ready \& $result = can_read($fh, $timeout); \& $result = can_write($fh, $timeout); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Provides unbuffered blocking I/O functions to read and write FastCGI messages. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .SS "read_header" .IX Subsection "read_header" Attempts to read a \f(CW\*(C`FCGI_Header\*(C'\fR from file handle \f(CW$fh\fR. .PP \&\fIUsage\fR .PP .Vb 2 \& ($type, $request_id, $content_length, $padding_length) \& = read_header($fh); \& \& $header = read_header($fh); \& say $header\->{type}; \& say $header\->{request_id}; \& say $header\->{content_length}; \& say $header\->{padding_length}; .Ve .PP \&\fIArguments\fR .ie n .IP "$fh" 4 .el .IP "\f(CW$fh\fR" 4 .IX Item "$fh" The file handle to read from. Must be a file handle with a file descriptor. File handle mode should be set to binary. .PP \&\fIReturns\fR .PP Upon successful completion, the return value of \*(L"parse_header\*(R" in Net::FastCGI::Protocol. Otherwise, a false value (\f(CW\*(C`undef\*(C'\fR in scalar context and an empty list in list context). .PP If \f(CW\*(C`read_header\*(C'\fR reaches end-of-file before reading any octets, it returns a false value. If unsuccessful, \f(CW\*(C`read_header\*(C'\fR returns a false value and \f(CW$!\fR contains the error from the \f(CW\*(C`sysread\*(C'\fR call. If \f(CW\*(C`read_header\*(C'\fR encounters end-of-file after some but not all of the needed octets, the function returns a false value and sets \f(CW$!\fR to \f(CW\*(C`EPIPE\*(C'\fR. .PP \&\fIImplementation\fR .PP The implementation calls \f(CW\*(C`sysread\*(C'\fR in a loop, restarting if \f(CW\*(C`sysread\*(C'\fR returns \f(CW\*(C`undef\*(C'\fR with \f(CW$!\fR set to \f(CW\*(C`EINTR\*(C'\fR. If \f(CW\*(C`sysread\*(C'\fR does not provide all the requested octets, \f(CW\*(C`read_header\*(C'\fR continues to call \f(CW\*(C`sysread\*(C'\fR until either all the octets have been read, reaches end-of-file or an error occurs. .SS "read_record" .IX Subsection "read_record" Attempts to read a \f(CW\*(C`FCGI_Record\*(C'\fR from file handle \f(CW$fh\fR. .PP \&\fIUsage\fR .PP .Vb 2 \& ($type, $request_id, $content) \& = read_record($fh); \& \& $record = read_record($fh); \& say $record\->{type}; \& say $record\->{request_id}; .Ve .PP \&\fIArguments\fR .ie n .IP "$fh" 4 .el .IP "\f(CW$fh\fR" 4 .IX Item "$fh" The file handle to read from. Must be a file handle with a file descriptor. File handle mode should be set to binary. .PP \&\fIReturns\fR .PP Upon successful completion, the return value of \*(L"parse_record\*(R" in Net::FastCGI::Protocol. Otherwise, a false value (\f(CW\*(C`undef\*(C'\fR in scalar context and an empty list in list context). .PP If \f(CW\*(C`read_record\*(C'\fR reaches end-of-file before reading any octets, it returns a false value. If unsuccessful, \f(CW\*(C`read_record\*(C'\fR returns a false value and \f(CW$!\fR contains the error from the \f(CW\*(C`sysread\*(C'\fR call. If \f(CW\*(C`read_record\*(C'\fR encounters end-of-file after some but not all of the needed octets, the function returns a false value and sets \f(CW$!\fR to \f(CW\*(C`EPIPE\*(C'\fR. .PP \&\fIImplementation\fR .PP The implementation calls \f(CW\*(C`sysread\*(C'\fR in a loop, restarting if \f(CW\*(C`sysread\*(C'\fR returns \f(CW\*(C`undef\*(C'\fR with \f(CW$!\fR set to \f(CW\*(C`EINTR\*(C'\fR. If \f(CW\*(C`sysread\*(C'\fR does not provide all the requested octets, \f(CW\*(C`read_record\*(C'\fR continues to call \f(CW\*(C`sysread\*(C'\fR until either all the octets have been read, reaches end-of-file or an error occurs. .SS "write_header" .IX Subsection "write_header" Attempts to write a \f(CW\*(C`FCGI_Header\*(C'\fR to file handle \f(CW$fh\fR. .PP \&\fIUsage\fR .PP .Vb 1 \& $result = write_header($fh, $type, $request_id, $content_length, $padding_length); .Ve .PP \&\fIArguments\fR .ie n .IP "$fh" 4 .el .IP "\f(CW$fh\fR" 4 .IX Item "$fh" The file handle to write to. Must be a file handle with a file descriptor. File handle mode should be set to binary. .ie n .IP "$type" 4 .el .IP "\f(CW$type\fR" 4 .IX Item "$type" An unsigned 8\-bit integer. .ie n .IP "$request_id" 4 .el .IP "\f(CW$request_id\fR" 4 .IX Item "$request_id" An unsigned 16\-bit integer. .ie n .IP "$content_length" 4 .el .IP "\f(CW$content_length\fR" 4 .IX Item "$content_length" An unsigned 16\-bit integer. .ie n .IP "$padding_length" 4 .el .IP "\f(CW$padding_length\fR" 4 .IX Item "$padding_length" An unsigned 8\-bit integer. .PP \&\fIReturns\fR .ie n .IP "$result" 4 .el .IP "\f(CW$result\fR" 4 .IX Item "$result" Upon successful completion, the number of octets actually written. Otherwise, \&\f(CW\*(C`undef\*(C'\fR and \f(CW$!\fR contains the error from the \f(CW\*(C`syswrite\*(C'\fR call. .PP \&\fIImplementation\fR .PP The implementation calls \f(CW\*(C`syswrite\*(C'\fR in a loop, restarting if \f(CW\*(C`syswrite\*(C'\fR returns \f(CW\*(C`undef\*(C'\fR with \f(CW$!\fR set to \f(CW\*(C`EINTR\*(C'\fR. If \f(CW\*(C`syswrite\*(C'\fR does not output all the requested octets, \f(CW\*(C`write_header\*(C'\fR continues to call \f(CW\*(C`syswrite\*(C'\fR until all the octets have been written or an error occurs. .SS "write_record" .IX Subsection "write_record" Attempts to write a \f(CW\*(C`FCGI_Record\*(C'\fR to file handle \f(CW$fh\fR. .PP \&\fIUsage\fR .PP .Vb 2 \& $result = write_record($fh, $type, $request_id); \& $result = write_record($fh, $type, $request_id, $content); .Ve .PP \&\fIArguments\fR .ie n .IP "$fh" 4 .el .IP "\f(CW$fh\fR" 4 .IX Item "$fh" The file handle to write to. Must be a file handle with a file descriptor. File handle mode should be set to binary. .ie n .IP "$type" 4 .el .IP "\f(CW$type\fR" 4 .IX Item "$type" An unsigned 8\-bit integer. .ie n .IP "$request_id" 4 .el .IP "\f(CW$request_id\fR" 4 .IX Item "$request_id" An unsigned 16\-bit integer. .ie n .IP "$content (optional)" 4 .el .IP "\f(CW$content\fR (optional)" 4 .IX Item "$content (optional)" A string of octets containing the content, cannot exceed 65535 octets in length. .PP \&\fIReturns\fR .ie n .IP "$result" 4 .el .IP "\f(CW$result\fR" 4 .IX Item "$result" Upon successful completion, the number of octets actually written. Otherwise, \&\f(CW\*(C`undef\*(C'\fR and \f(CW$!\fR contains the error from the \f(CW\*(C`syswrite\*(C'\fR call. .PP \&\fIImplementation\fR .PP The implementation calls \f(CW\*(C`syswrite\*(C'\fR in a loop, restarting if \f(CW\*(C`syswrite\*(C'\fR returns \f(CW\*(C`undef\*(C'\fR with \f(CW$!\fR set to \f(CW\*(C`EINTR\*(C'\fR. If \f(CW\*(C`syswrite\*(C'\fR does not output all the requested octets, \f(CW\*(C`write_record\*(C'\fR continues to call \f(CW\*(C`syswrite\*(C'\fR until all the octets have been written or an error occurs. .SS "write_stream" .IX Subsection "write_stream" Attempts to write a \f(CW\*(C`FCGI_Record\*(C'\fR stream to file handle \f(CW$fh\fR. .PP \&\fIUsage\fR .PP .Vb 2 \& $result = write_stream($fh, $type, $request_id, $content); \& $result = write_stream($fh, $type, $request_id, $content, $terminate); .Ve .PP \&\fIArguments\fR .ie n .IP "$fh" 4 .el .IP "\f(CW$fh\fR" 4 .IX Item "$fh" The file handle to write to. Must be a file handle with a file descriptor. File handle mode should be set to binary. .ie n .IP "$type" 4 .el .IP "\f(CW$type\fR" 4 .IX Item "$type" An unsigned 8\-bit integer. .ie n .IP "$request_id" 4 .el .IP "\f(CW$request_id\fR" 4 .IX Item "$request_id" An unsigned 16\-bit integer. .ie n .IP "$content" 4 .el .IP "\f(CW$content\fR" 4 .IX Item "$content" A string of octets containing the stream content. .ie n .IP "$terminate (optional)" 4 .el .IP "\f(CW$terminate\fR (optional)" 4 .IX Item "$terminate (optional)" A boolean indicating whether or not the stream should be terminated. Defaults to false. .PP \&\fIReturns\fR .ie n .IP "$result" 4 .el .IP "\f(CW$result\fR" 4 .IX Item "$result" Upon successful completion, the number of octets actually written. Otherwise, \&\f(CW\*(C`undef\*(C'\fR and \f(CW$!\fR contains the error from the \f(CW\*(C`syswrite\*(C'\fR call. .PP \&\fIImplementation\fR .PP The implementation calls \f(CW\*(C`syswrite\*(C'\fR in a loop, restarting if \f(CW\*(C`syswrite\*(C'\fR returns \f(CW\*(C`undef\*(C'\fR with \f(CW$!\fR set to \f(CW\*(C`EINTR\*(C'\fR. If \f(CW\*(C`syswrite\*(C'\fR does not output all the requested octets, \f(CW\*(C`write_stream\*(C'\fR continues to call \f(CW\*(C`syswrite\*(C'\fR until all the octets have been written or an error occurs. .SS "can_read" .IX Subsection "can_read" Determines whether or not the given file handle \f(CW$fh\fR is ready for reading within the given timeout \f(CW$timeout\fR. .PP \&\fIUsage\fR .PP .Vb 1 \& $result = can_read($fh, $timeout); .Ve .PP \&\fIArguments\fR .ie n .IP "$fh" 4 .el .IP "\f(CW$fh\fR" 4 .IX Item "$fh" The file handle to test for readiness. Must be a file handle with a file descriptor. .ie n .IP "$timeout" 4 .el .IP "\f(CW$timeout\fR" 4 .IX Item "$timeout" Maximum interval to wait. Can be set to either a non-negative numeric value or \&\f(CW\*(C`undef\*(C'\fR for infinite wait. .PP \&\fIReturns\fR .PP Upon successful completion, \f(CW0\fR or \f(CW1\fR. Otherwise, \f(CW\*(C`undef\*(C'\fR and \f(CW$!\fR contains the \f(CW\*(C`select\*(C'\fR error. .PP \&\fIImplementation\fR .PP The implementation calls \f(CW\*(C`select\*(C'\fR in a loop, restarting if \f(CW\*(C`select\*(C'\fR returns \&\f(CW\*(C`\-1\*(C'\fR with \f(CW$!\fR set to \f(CW\*(C`EINTR\*(C'\fR and \f(CW$timeout\fR has not elapsed. .SS "can_write" .IX Subsection "can_write" Determines whether or not the given file handle \f(CW$fh\fR is ready for writing within the given timeout \f(CW$timeout\fR. .PP \&\fIUsage\fR .PP .Vb 1 \& $result = can_write($fh, $timeout); .Ve .PP \&\fIArguments\fR .ie n .IP "$fh" 4 .el .IP "\f(CW$fh\fR" 4 .IX Item "$fh" The file handle to test for readiness. Must be a file handle with a file descriptor. .ie n .IP "$timeout" 4 .el .IP "\f(CW$timeout\fR" 4 .IX Item "$timeout" Maximum interval to wait. Can be set to either a non-negative numeric value or \&\f(CW\*(C`undef\*(C'\fR for infinite wait. .PP \&\fIReturns\fR .PP Upon successful completion, \f(CW0\fR or \f(CW1\fR. Otherwise, \f(CW\*(C`undef\*(C'\fR and \f(CW$!\fR contains the \f(CW\*(C`select\*(C'\fR error. .PP \&\fIImplementation\fR .PP The implementation calls \f(CW\*(C`select\*(C'\fR in a loop, restarting if \f(CW\*(C`select\*(C'\fR returns \&\f(CW\*(C`\-1\*(C'\fR with \f(CW$!\fR set to \f(CW\*(C`EINTR\*(C'\fR and \f(CW$timeout\fR has not elapsed. .SH "EXPORTS" .IX Header "EXPORTS" None by default. All functions can be exported using the \f(CW\*(C`:all\*(C'\fR tag or individually. .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" .ie n .IP "\fB(F)\fR Usage: %s" 4 .el .IP "\fB(F)\fR Usage: \f(CW%s\fR" 4 .IX Item "(F) Usage: %s" Subroutine called with wrong number of arguments. .ie n .IP "\fB(W Net::FastCGI::IO)\fR FastCGI: Could not read %s" 4 .el .IP "\fB(W Net::FastCGI::IO)\fR FastCGI: Could not read \f(CW%s\fR" 4 .IX Item "(W Net::FastCGI::IO) FastCGI: Could not read %s" .PD 0 .ie n .IP "\fB(W Net::FastCGI::IO)\fR FastCGI: Could not write %s" 4 .el .IP "\fB(W Net::FastCGI::IO)\fR FastCGI: Could not write \f(CW%s\fR" 4 .IX Item "(W Net::FastCGI::IO) FastCGI: Could not write %s" .PD .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "FastCGI Specification Version 1.0" 4 .IX Item "FastCGI Specification Version 1.0" .IP "The Common Gateway Interface (\s-1CGI\s0) Version 1.1" 4 .IX Item "The Common Gateway Interface (CGI) Version 1.1" .IP "Net::FastCGI::Constant" 4 .IX Item "Net::FastCGI::Constant" .PD 0 .IP "Net::FastCGI::Protocol" 4 .IX Item "Net::FastCGI::Protocol" .PD .SH "AUTHOR" .IX Header "AUTHOR" Christian Hansen \f(CW\*(C`chansen@cpan.org\*(C'\fR .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2008\-2010 by Christian Hansen. .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.