P
Peter J. Holzer
Does IO::Select take into account data buffered by PerlIO?
Specifically, I would like to do something like the following:
my $s = IO::Select->new();
$s->add($socket_fh);
while (...) {
print $socket_fh "$request\n";
while ($s->can_read(0)) {
my $response = <$socket_fh>;
# do something with $response
}
}
to exploit pipelining in a protocol.
This wouldn't work with stdio and select(2) in C, but in C, the system
call select is at a lower layer than the stdio and cannot know about
stdio buffers, while in Perl, IO::Select works on filehandles so one
could hope that it is smart enough to know about them. I can't find
anything about that in the docs, though.
(perldoc -f select says you have to use sysread, but select uses fd
numbers, not filehandles)
hp
Specifically, I would like to do something like the following:
my $s = IO::Select->new();
$s->add($socket_fh);
while (...) {
print $socket_fh "$request\n";
while ($s->can_read(0)) {
my $response = <$socket_fh>;
# do something with $response
}
}
to exploit pipelining in a protocol.
This wouldn't work with stdio and select(2) in C, but in C, the system
call select is at a lower layer than the stdio and cannot know about
stdio buffers, while in Perl, IO::Select works on filehandles so one
could hope that it is smart enough to know about them. I can't find
anything about that in the docs, though.
(perldoc -f select says you have to use sysread, but select uses fd
numbers, not filehandles)
hp