in reply to Re: chargen program is too slow / IO::Select socket handle outputting timing issue
in thread chargen program is too slow / IO::Select socket handle outputting timing issue

I think part of the problem is the slightly awkward syntax of the IO::Select->select($sel, $sel); and the fact that there is no example of this call in IO::Select's docs.

I think it would make a lot of sense to have a method like this:

my ($rready, $wready) = $sel->can([TIMEOUT]);
or maybe even better
my ($rready, $wready) = $sel->select([TIMEOUT]);
Looking at the code in IO::Select.pm it seems to me the only change necessary would be on lines 181-184:
- shift - if defined $_[0] && !ref($_[0]); - - my($r,$w,$e,$t) = @_; + my($r,$w,$e,$t); + if (defined $_[0] && !ref($_[0])) { # called as a static method + shift; + ($r,$w,$e,$t) = @_; + } elsif (@_ == 1 || @_ == 2 && !ref($_[1])) { # called as $sel->sele +ct() or $sel->select($timeout) + $r=$w=$e=$_[0]; + $t=$_[1]; + } else { # called as IO::Select::select(...) + ($r,$w,$e,$t) = @_; + }
the question is whether anyone would notice that $sel->select() not longer means IO::Select->select($sel) but rather IO::Select->select($sel,$sel,$sel)

Replies are listed 'Best First'.
Re^3: chargen program is too slow / IO::Select socket handle outputting timing issue
by ikegami (Patriarch) on Jul 14, 2006 at 14:51 UTC

    The first two arguments of IO::Select->select are rarely the same, so I'm not sure that's a useful patch. In fact, the first two arguments should be different in your code. (Why are you waiting to write to the listen socket?) It should look more like:

    my $rsel = IO::Select->new(); my $wsel = IO::Select->new(); ... for (;;) { my ($rready, $wready) = IO::Select->select($rsel, $wsel); foreach my $rsocket (@$rready) { ... } foreach my $wsocket (@$wready) { ... } }