[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

select([]) method

Ari Brown

5/31/2007 2:35:00 AM

Hey all
I cam across a new method:
select([], [], [], [])
where the objects in the select parentheses are arrays.

But what does this exactly do? I could not find ANY documentation on
it. The original code is:

ready = select([@irc, $stdin], nil, nil, nil)

Any help please?
ari
-------------------------------------------------------|
~ Ari
crap my sig won't fit


5 Answers

Brian Candler

5/31/2007 7:15:00 AM

0

On Thu, May 31, 2007 at 11:34:57AM +0900, Ari Brown wrote:
> Hey all
> I cam across a new method:
> select([], [], [], [])
> where the objects in the select parentheses are arrays.
>
> But what does this exactly do? I could not find ANY documentation on
> it. The original code is:
>
> ready = select([@irc, $stdin], nil, nil, nil)
>
> Any help please?

Kernel#select is very poorly documented in ri. Try this instead:

http://www.rubycentral.com/book/ref_m_kernel.html#Ker...

Marcin Raczkowski

5/31/2007 9:39:00 AM

0

On Thursday 31 May 2007 02:34, Ari Brown wrote:
> Hey all
> I cam across a new method:
> select([], [], [], [])
> where the objects in the select parentheses are arrays.
>
> But what does this exactly do? I could not find ANY documentation on
> it. The original code is:
>
> ready = select([@irc, $stdin], nil, nil, nil)
>
> Any help please?
> ari
> -------------------------------------------------------|
> ~ Ari
> crap my sig won't fit

it's just wraper for c / linux select
you can try man select if you have libc documentation

--
Marcin Raczkowski
---
Friends teach what you should know
Enemies Teach what you have to know

Felipe Contreras

5/31/2007 2:13:00 PM

0

On 5/31/07, Ari Brown <ari@aribrown.com> wrote:
> Hey all
> I cam across a new method:
> select([], [], [], [])
> where the objects in the select parentheses are arrays.
>
> But what does this exactly do? I could not find ANY documentation on
> it. The original code is:
>
> ready = select([@irc, $stdin], nil, nil, nil)

I agree with other comments, the documentation for select is pretty bad.

The most simple way to use it is like this:

svrs = IO.select([my_fd], nil, nil, 0)
svrs[0].each { |io| puts io.readline }

--
Felipe Contreras

Avdi Grimm

5/31/2007 2:36:00 PM

0

In a nutshell, select() is a system call for use when you have
multiple IO events pending, and you want to handle the first one that
occurs. So for instance if you have three network connections, and
you need wait until data comes in on one of them, you could use
select().

--
Avdi

Ari Brown

5/31/2007 7:58:00 PM

0


On May 31, 2007, at 10:12 AM, Felipe Contreras wrote:

> On 5/31/07, Ari Brown <ari@aribrown.com> wrote:
>> Hey all
>> I cam across a new method:
>> select([], [], [], [])
>> where the objects in the select parentheses are arrays.
>>
>> But what does this exactly do? I could not find ANY documentation on
>> it. The original code is:
>>
>> ready = select([@irc, $stdin], nil, nil, nil)
>
> I agree with other comments, the documentation for select is pretty
> bad.
>
> The most simple way to use it is like this:
>
> svrs = IO.select([my_fd], nil, nil, 0)
> svrs[0].each { |io| puts io.readline }

Alright, thanks everyone! This really cleared it up, and now i
learned like 800 new things about ruby. BTW, the link that was tossed
was definitely a great link. Thanks!

ari
--------------------------------------------|
If you're not living on the edge,
then you're just wasting space.