J
James Marshall
I need to read data from a socket, with sysread-style blocking (i.e. block
if no data available, but return immediately with anything that is
available, possibly less than the requested amount). Is this possible
when using buffered I/O (read(), <S>), or only with non-buffered I/O
(sysread(), recv())?
I can't use non-blocking I/O, because that implies a busy loop when no
data is available (doesn't it?).
I can't use select(), because that won't work with buffered I/O (will
it?).
I can't really use signals, because the program can't really continue
until it has the data.
How does one do this? Am I missing something, or making a bad assumption
somewhere? Has anyone documented the "heavy wizardry" that's required to
use buffered I/O and non-buffered I/O on the same socket? I'd really
rather not rewrite my (large) program to use unbuffered I/O... that could
get messy. Socket flags and fcntl() etc. are allowed, as long as it's
reasonably portable. Standard modules are OK too, but ideally for this
application I don't want to require the user to install extra modules.
Since that's not restrictive enough, ideally I'd also like it to run in
Perl 5.6.1, but I'm flexible on that.
Thanks a lot for any ideas!
James
.............................................................................
James Marshall (e-mail address removed) Berkeley, CA @}-'-,--
"Teach people what you know."
.............................................................................
if no data available, but return immediately with anything that is
available, possibly less than the requested amount). Is this possible
when using buffered I/O (read(), <S>), or only with non-buffered I/O
(sysread(), recv())?
I can't use non-blocking I/O, because that implies a busy loop when no
data is available (doesn't it?).
I can't use select(), because that won't work with buffered I/O (will
it?).
I can't really use signals, because the program can't really continue
until it has the data.
How does one do this? Am I missing something, or making a bad assumption
somewhere? Has anyone documented the "heavy wizardry" that's required to
use buffered I/O and non-buffered I/O on the same socket? I'd really
rather not rewrite my (large) program to use unbuffered I/O... that could
get messy. Socket flags and fcntl() etc. are allowed, as long as it's
reasonably portable. Standard modules are OK too, but ideally for this
application I don't want to require the user to install extra modules.
Since that's not restrictive enough, ideally I'd also like it to run in
Perl 5.6.1, but I'm flexible on that.
Thanks a lot for any ideas!
James
.............................................................................
James Marshall (e-mail address removed) Berkeley, CA @}-'-,--
"Teach people what you know."
.............................................................................