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

I try to do this, but C function dont print to stream :( Maybe i have mistake in code?
sub main { my $proc_manager = new FCGI::ProcManager({ n_processes => $PRO +CESSES}); my $socket = FCGI::OpenSocket($SOCKET, 100); my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV +, $socket); my (undef, $out, undef) = $request->GetHandles(); $proc_manager->pm_manage(); while($request->Accept() >= 0){ $proc_manager->pm_pre_dispatch(); my $cgi = CGI::Fast->new(); print "Content-type: text/html\r\n\r\n"; my_print_c($out); $proc_manager->pm_post_dispatch(); } FCGI::CloseSocket($socket); } __END__ __C__ void my_print_c(SV * fh) { dSP; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(fh)); XPUSHs(sv_2mortal(newSVpv("TEXT", 0))); PUTBACK; call_pv("PRINT", G_DISCARD); FREETMPS; LEAVE; }

Replies are listed 'Best First'.
Re^7: Inline C + IO::Handle
by ikegami (Patriarch) on Apr 17, 2009 at 18:08 UTC

    You're doing

    PRINT($out, "TEXT");

    when you want to do

    tied(*$out)->PRINT("TEXT");
      Hmmm... I misled... :)
      I have to print text to fastcgi stream from C code, not perl code. Maybe i something not understand :(

        No, I understand. Let me rephrase. It's not working because you are doing the XS equivalent of

        PRINT($out, "TEXT");

        when you want to do the XS equivalent of

        tied(*$out)->PRINT("TEXT");