Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

select RBITS,WBITS,EBITS,TIMEOUT. The meaning of all the *BITS

by igoryonya (Monk)
on Oct 23, 2020 at 00:38 UTC ( #11123064=perlquestion: print w/replies, xml ) Need Help??

igoryonya has asked for the wisdom of the Perl Monks concerning the following question:

I am reading documentation on select command and I can't figure out, what these RBITS,WBITS,EBITS mean.

Well, I came to guess, that probably, RBITS - means Read Bits, WBITS - Write Bits, but what about EBITS, then?
What does this construct mean? What is it used for? Manual doesn't explain anything. Just throws these:

select RBITS,WBITS,EBITS,TIMEOUT
my ($nfound, $timeleft) = select(my $rout = $rin, my $wout = $win, my $eout = $ein, $timeout);
without any explanation.
  • Comment on select RBITS,WBITS,EBITS,TIMEOUT. The meaning of all the *BITS

Replies are listed 'Best First'.
Re: select RBITS,WBITS,EBITS,TIMEOUT. The meaning of all the *BITS
by Fletch (Chancellor) on Oct 23, 2020 at 02:04 UTC

    EBITS is for error filehandles. The select builtin is a thin layer over the underlying select(2) system call so familiarity with that can help (see your OS' manual pages or a tome like e.g. Stevens, Advanced Programming in the UNIX Environment).

    Unless you've got a burning desire to program that close to the metal as it were you may be better served using IO::Select (or stepping even further back and using an event loop like Mojo::IOLoop, AnyEvent, or POE).

    Edit: And I just bothered to pull my copy off the shelf and skim and I'm a bit vague still. That's filehandles which you want to know if/when they have errors or exception conditions present.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      EBITS is for error filehandles.

      No. What does that even mean? It's used to specify the handles to monitor for exceptional conditions. See my answer for details.

Re: select RBITS,WBITS,EBITS,TIMEOUT. The meaning of all the *BITS
by ikegami (Pope) on Oct 25, 2020 at 11:12 UTC

    It's used to specify the handles to monitor for exceptional conditions.

    If you need it, you'd know it.


    Perl's select is a thin wrapper for the system call of the same name.

    From my select(2) man page:

    The file descriptors in exceptfds will be watched for exceptional conditions. (For examples of some exceptional conditions, see the discussion of POLLPRI in poll(2).)

    From my poll(2) man page:

    POLLPRI

    There is some exceptional condition on the file descriptor. Possibilities include:

    • There is out-of-band data on a TCP socket (see tcp(7)).
    • A pseudoterminal master in packet mode has seen a state change on the slave (see ioctl_tty(2)).
    • A cgroup.events file has been modified (see cgroups(7)).

    By the way, IO::Select presents a much better interface.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11123064]
Approved by kcott
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2020-11-30 02:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?