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

Ok. I modified code like this:
void my_print(PerlIO *f) { PerlIO_puts(f,"abcdef"); }
but it still not work :( Perl "print $out 'TEXT';" work perfect but C "my_print" dot put chars to fastcgi stream. PerlIO_puts return -1 and errno set 9 (Bad file descriptor)

Replies are listed 'Best First'.
Re^5: Inline C + IO::Handle
by gone2015 (Deacon) on Apr 15, 2009 at 18:00 UTC

    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.

Re^5: Inline C + IO::Handle
by ikegami (Patriarch) on Apr 15, 2009 at 16:46 UTC
    Sorry, I've never actually used this and I don't have time to learn it right now. Can anyone else help this monk?