Geoffrey Young wrote:
>
> yes, it worked for me.  actually, I guess I should have been clearer - this
> has nothing to do with $c->aborted or $r->print (well, on the outside
> anyway).  for $c->aborted you have to wait for Apache to flush the print
> buffers.  actually, in my tests $r->rflush didn't help things behave - only
> $|=1 did.
> 

Hey Geoff, for efficiency, my final code for detecting a client abort is:

sub Apache::ASP::Response::IsClientConnected {
    ...
    # IsClientConnected ?  Might already be disconnected for busy site, if
    # a user hits stop/reload
    my $conn = $self->{r}->connection;
    my $is_connected = $conn->aborted ? 0 : 1;
    if($is_connected) {
        my $fileno = $conn->fileno;
        if(defined $fileno) {
            my $s = IO::Select->new($fileno);
            $is_connected = $s->can_read(0) ? 0 : 1;
        }
    }

where $self is the ASP object ... I looked at the IO::Select->new()
and it looked pretty hairy, so I checked connection->aborted
status first in case it was already set.

-- Josh
_________________________________________________________________
Joshua Chamas                           Chamas Enterprises Inc.
NodeWorks Founder                       Huntington Beach, CA  USA 
http://www.nodeworks.com                1-714-625-4051

Reply via email to