我正在使用IO::Select .
它是 normal select
call 的 OOP 包装器,但它公开了 can_read()
和 can_write()
方法。有没有办法阻止等待读或写套接字?这不是(几乎)违背了 IO::Select 的初衷吗?
最佳答案
select ( READ, WRITE, EXCEPTION [, TIMEOUT ] )
select
is a static method, that is you call it with the package name likenew
.READ
,WRITE
andEXCEPTION
are eitherundef
orIO::Select
objects.TIMEOUT
is optional and has the same effect as for the core select call.The result will be an array of 3 elements, each a reference to an array which will hold the handles that are ready for reading, writing and have exceptions respectively. Upon error an empty list is returned.
例如:
my $rsel = IO::Select->new($rfh);
my $wsel = IO::Select->new($wfh);
my $esel = IO::Select->new($rfh, $wfh);
my @ready = IO::Select->select($rsel, $wsel, $esel, undef);
关于perl - 如何使用 IO::Select 阻止等待读取或写入套接字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42151567/