in reply to chargen program is too slow / IO::Select socket handle outputting timing issue
Gah, IO::Select's design sure encourages people to use it badly for cases where they are doing more than just reading or just writing. You've fallen victim to this design. It could really use another layer. I should write a patch... but not at the momement.
The "proper" way to use IO::Select for a case like this, is more like:
while( 1 ) { my( $readers, $writers )= IO::Select->select( $sel, $sel, unde +f ); foreach my $socket ( @$readers ) { if( $socket == $server_sock ) { new_socket( $socket ); } elsif( defined($socket) ) { close_socket($socket); } } foreach my $socket ( @$writers ) { gen_chars( $socket ); } }
Which will be fast and not wasteful of CPU, which are major points of select (rather than just preventing blocking).
- tye
|
|---|