Using select(2)

Discussion in 'Perl' started by memyself_, Jan 30, 2005.

  1. memyself_

    memyself_ Guest

    Dear,

    using the following:

     my($scount, $stime)=
     CORE::select( $read_bits,
                    $write_bits,
                    $err_bits, 1);

    In my program, $scount is allways equal to -1,
    and $read_bits, $write_bits, $err_bits, to 0.

    Does anybody know in wich case it can happen?

    thank's in advance
     
    memyself_, Jan 30, 2005
    #1
    1. Advertisements

  2. memyself_

    Joe Smith Guest

    memyself_ wrote:

    > my($scount, $stime)=
    > CORE::select( $read_bits,
    > $write_bits,
    > $err_bits, 1);
    >
    > In my program, $scount is allways equal to -1,
    > and $read_bits, $write_bits, $err_bits, to 0.


    You did not show us where you were setting $read_bits and such
    to be nonzero. You have to set them before each time select()
    is called.

    $rb = one bit for each file handle you will be reading from
    $wb = one bit for each file handle you will be writing to
    $eb = $rb | $wb;
    $ms = 1.0; # seconds for the timeout
    ($scount,$stime) = select( $read_bits=$rb, $write_bits=$wb,
    $error_bits=$eb, $ms);
    warn "Invalid arguments presented to select()" if $scount < 0;
    if ($scount == 0) {
    print "No file handles are ready for I/O\n";
    } else {
    print "Can do I/O: r=$read_bits w=$write_bits e=$error_bits\n";
    }
    print "$stime seconds left before timeout\n" if $stime;

    Use 'perldoc -f select' for more info.
    Use comp.lang.perl.misc (and not comp.lang.perl) next time.
    -Joe
     
    Joe Smith, Jan 31, 2005
    #2
    1. Advertisements

  3. memyself_

    Jim Gibson Guest

    In article <ctip38$1qi$>, memyself_ <>
    wrote:

    > Dear,
    >
    > using the following:
    >
    >  my($scount, $stime)=
    >  CORE::select( $read_bits,
    >                 $write_bits,
    >                 $err_bits, 1);
    >
    > In my program, $scount is allways equal to -1,
    > and $read_bits, $write_bits, $err_bits, to 0.


    Sorry, but I am not familiar with the CORE module, and it is not
    mentioned in my Perl book nor found on CPAN. Assuming it is just the
    Perl built-in select function that calls the normal Unix select system
    call, then you need to set the appropriate bits of $read_bits,
    $write_bits, and $err_bits in order for this call to do anything. If
    these are all zero, select will return after waiting for the specified
    amount of time (1 second in your example) and will never set any bits
    in the argument variables.

    See 'perldoc -f select' to see how to set and inspect the appropriate
    bits to check a particular file handle.

    FYI: this newsgroup is defunct; use comp.lang.perl.misc in the future.


    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
     
    Jim Gibson, Jan 31, 2005
    #3
  4. memyself_

    memyself_ Guest

    Jim Gibson wrote:

    > In article <ctip38$1qi$>, memyself_ <>
    > wrote:
    >
    >> Dear,
    >>
    >> using the following:
    >>
    >> my($scount, $stime)=
    >> CORE::select( $read_bits,
    >> $write_bits,
    >> $err_bits, 1);
    >>
    >> In my program, $scount is allways equal to -1,
    >> and $read_bits, $write_bits, $err_bits, to 0.

    >
    > Sorry, but I am not familiar with the CORE module, and it is not
    > mentioned in my Perl book nor found on CPAN. Assuming it is just the
    > Perl built-in select function that calls the normal Unix select system
    > call, then you need to set the appropriate bits of $read_bits,
    > $write_bits, and $err_bits in order for this call to do anything. If
    > these are all zero, select will return after waiting for the specified
    > amount of time (1 second in your example) and will never set any bits
    > in the argument variables.


    The CORE module is for the perl built-in functions,
    to distinguish thelmseve from user functions.
    I write it like that to have a high level select subroutine slighty
    different from the IO::Select module.

    I found the reason by myself today. select return -1 because none of the
    bits string are set. I know where to find the bug now.

    Thank's for your answers
     
    memyself_, Jan 31, 2005
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGFiYmxlcg==?=

    select gridview row without using select button?

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 3, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    101,733
    dch31969
    Feb 27, 2009
  2. J. Hall
    Replies:
    2
    Views:
    1,171
    Jeff Thies
    Apr 21, 2004
  3. palmiere
    Replies:
    1
    Views:
    520
    Erwin Moller
    Feb 9, 2004
  4. Bonge Boo!
    Replies:
    5
    Views:
    266
    Bonge Boo!
    Apr 25, 2005
  5. Replies:
    2
    Views:
    221
Loading...

Share This Page