in reply to Re^6: Check connection state prior to send data
in thread Check connection state prior to send data
Adapting the SYNOPSIS gives me the following code:
use IO::Select; $s = IO::Select->new(); ... $s->add($some_handle); my $outbuffer; while( $running ) { if( length $outbuffer ) { my @writeable = $s->can_write($timeout); for my $client (@writeable) { print {$client} $outbuffer; # In reality, we'd need to maintain an outbuffer per c +lient, but # that's not the point here }; undef $outbuffer; } else { $outbuffer = refill_outbuffer; }; };
|
|---|