# Buffers to flush? foreach $client ($select->can_write(1)) { # Skip this client if we have nothing to say next unless exists $outbuffer{$client}; $rv = send($client, $outbuffer{$client}, 0); if ($! == POSIX::EWOULDBLOCK) { #caught a EWOULDBLOCK. Ignore. } elsif (! defined $rv) { # Whine, but move on. warn "I was told I could write, but I can't : $!\n"; next; } elsif ($rv) { substr($outbuffer{$client}, 0, $rv) = ''; warn "successfully wrote $rv bytes\n" if length $outbuffer{$client}; delete $outbuffer{$client} unless length $outbuffer{$client}; } else { # Couldn't write all the data, and it wasn't because # it would have blocked. Shutdown and move on. warn "Failed to write all data, \$rv was $rv, \$! was ".($!+0).", length was ".(length $outbuffer{$client})."\n"; $self->disconnect_client($client); next; } }