in reply to Re^5: Check connection state prior to send data
in thread Check connection state prior to send data

Ok, maybe I don't understand how the IO::Select works. :(
Could you please post an example on how I can implement it? Thank you!!
  • Comment on Re^6: Check connection state prior to send data

Replies are listed 'Best First'.
Re^7: Check connection state prior to send data
by Corion (Patriarch) on Sep 24, 2016 at 09:16 UTC

    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; }; };