Hideki Noma wrote: > I am currently developping a private module utilizing > PerlProcessConnection handler and facing a bit of problem. > (Apache::2.0.39 + mod_perl 1.99.04) > > This is the part of program: > sub handler { > my Apache::Connection $c = shift; > my APR::Socket $socket = $c->client_socket; > > my($rlen, $wlen); > my $rlen = BUFF_LEN; > $socket->recv($buff, $rlen); > > At this point, if there is no incoming data from client, > the program halts forever. > > What I want to do is something like > my $sel = IO::Select->new($socket); > if ($sel->can_read(1)){ > my $socket->recv($buff, $rlen); > } > so that I can do other works while waiting for data. > > I tried to set timeout using $socket->setsocketopt(APR_SO_TIMEOUT,1) > but it didn't seem to work well. > > Does any body have any idea on how to check incoming data avaliabily > on APR::Socket?
According to the apr/include/apr_network_io.h doc, you should be using $socket->timeout_set($timeout), before reading from the socket. so the recv() will return either with the data read or after the timeout, providing the non-blocking mechanism. Though, this API seems to be a recent thing and it's not supported by mod_perl, yet. I suppose that it'll be supported in the next release (or the cvs version. watch the dev list, where I've just posted the patch) __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com