You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Subhash Sankuratripati <su...@Yodlee.com> on 2000/09/08 01:10:41 UTC

Writing to the client's socket from an XS module

Hello,
	I would like to find out how can I write to the HTTP Client from an
XS module written in C being called from a Perl module running under apache.

	Even trying syswrite 1, "test" does not work from mod_perl. So
internally mod_perl is duping stdout to some other file handle and
eventually writing it to the accepted socket desc. from the client.

	Is there any way of writing to the filehandle from an XS module
written in C?.

Would really appreciate any way of implementing this.

Thanks in advance,
-Subhash.

Re: Writing to the client's socket from an XS module

Posted by Doug MacEachern <do...@covalent.net>.
On Thu, 7 Sep 2000, Subhash Sankuratripati wrote:

> Hello,
> 	I would like to find out how can I write to the HTTP Client from an
> XS module written in C being called from a Perl module running under apache.
> 
> 	Even trying syswrite 1, "test" does not work from mod_perl. So
> internally mod_perl is duping stdout to some other file handle and
> eventually writing it to the accepted socket desc. from the client.

mod_perl does not touch stdout.  under cgi, stdout is connected to a
pipe which is fed back to the client by mod_cgi, not the case with 
mod_perl.

have a look at Apache::Peek on cpan, which redirects stderr to the client
with a few defines:

#ifdef MOD_PERL
#include "modules/perl/mod_perl.h"

#undef PerlIO
#undef PerlIO_printf
#undef PerlIO_vprintf
#undef PerlIO_stderr
#undef PerlIO_putc
#undef PerlIO_puts

#define PerlIO request_rec
#define PerlIO_printf rprintf
#define PerlIO_vprintf(r,fmt,vlist) \
 vbprintf(r->connection->client, fmt, vlist)
#define PerlIO_stderr() perl_request_rec(NULL)
#define PerlIO_putc(r,c) rputc(c,r)
#define PerlIO_puts(r,s) rputs(s,r)