Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: Inline C + IO::Handle

by gone2015 (Deacon)
on Apr 15, 2009 at 18:00 UTC ( [id://757746] : note . print w/replies, xml ) Need Help??


in reply to Re^4: Inline C + IO::Handle
in thread FCGI + Inline::C fast stream out!

I tried the following:

use strict ; use warnings ; use Inline (Config => DIRECTORY => "$ENV{HOME}/PLIB/INLINE") ; use Inline 'C'; open my $fh, ">", "test.txt" ; my $rc = my_puts($fh) ; close $fh ; print "\$rc = $rc\n" ; __END__ __C__ int my_puts(PerlIO* fh) { return PerlIO_puts(fh, "Hello World !!\n") ; } ;
and got the expected non-negative return code and the file test.txt ended up containing "Hello World !!\n"...

...I regret I cannot say why your attempt to output to a fastcgi stream is failing... but I can confirm that it is generally possible to use PerlIO "file handles", and output via the PerlIO_xxx API as suggested. It's worth noting that PerlIO_puts has arguments in the opposite order to fputs -- but looks pretty straightforward otherwise. I guess there could be something peculiar about the $out file handle you have... Wish I could help more.