select([]) method

A

Ari Brown

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
 
M

Marcin Raczkowski

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
 
F

Felipe Contreras

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 }
 
A

Avdi Grimm

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().
 
A

Ari Brown

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,223
Latest member
Jurgen2087

Latest Threads

Top