Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Using select(2)

Reply
Thread Tools

Using select(2)

 
 
memyself_
Guest
Posts: n/a
 
      01-30-2005
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
 
Reply With Quote
 
 
 
 
Joe Smith
Guest
Posts: n/a
 
      01-31-2005
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
 
Reply With Quote
 
 
 
 
Jim Gibson
Guest
Posts: n/a
 
      01-31-2005
In article <ctip38$1qi$(E-Mail Removed)>, memyself_ <(E-Mail Removed)>
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 =---
 
Reply With Quote
 
memyself_
Guest
Posts: n/a
 
      01-31-2005
Jim Gibson wrote:

> In article <ctip38$1qi$(E-Mail Removed)>, memyself_ <(E-Mail Removed)>
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a Link Button to redirect to another page by using data from =?Utf-8?B?R1REcml2ZXI=?= ASP .Net 1 02-16-2005 07:04 PM
Error page using the Application_Error void dosnt work when using DIV for a please wait message s_erez@hotmail.com ASP .Net 2 12-24-2004 12:11 PM
no code in webform using vs.net, but in webform using notepad timmso ASP .Net 1 12-12-2003 04:30 PM
Using GetOleDbSchemaTable to get SQL Server Field Description - using pete ASP .Net 1 08-29-2003 10:50 AM
Re: MVP? Index error on nested element using System.xml but NOT using msxml??? William F. Robertson, Jr. ASP .Net 1 06-25-2003 08:08 PM



Advertisments