Forum: Ruby select([]) method

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ari B. (Guest)
on 2007-05-31 06:36
(Received via mailing list)
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
Mark Day (Guest)
on 2007-05-31 07:41
(Received via mailing list)
On May 30, 2007, at 7:34 PM, Ari B. wrote:

>   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:

$ ri select
More than one method matched your request. You can refine
your search by asking for information on one of:

      Array#select, Enumerable#select, Hash#select, IO::select,
      IRB::InputCompletor::select_message, Kernel#select,
      MatchData#select, Net::IMAP#select, Struct#select,
      URI::Generic#select, YAML::BaseNode#select!,
YAML::BaseNode#select,
      YAML::DBM#select

I think you're talking about IO::select:

$ ri IO::select
------------------------------------------------------------- IO::select
      IO.select(read_array
      [, write_array
      [, error_array
      [, timeout]]] ) =>  array  or  nil
------------------------------------------------------------------------

It looks like you're using Mac OS X, so try doing "man select" from
the Terminal for information on the underlying select() function in
the OS.

-Mark
Brian C. (Guest)
on 2007-05-31 11:16
(Received via mailing list)
On Thu, May 31, 2007 at 11:34:57AM +0900, Ari B. wrote:
> Any help please?
Kernel#select is very poorly documented in ri. Try this instead:

http://www.rubycentral.com/book/ref_m_kernel.html#...
Marcin R. (Guest)
on 2007-05-31 13:39
(Received via mailing list)
On Thursday 31 May 2007 02:34, Ari B. wrote:
> 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
Felipe C. (Guest)
on 2007-05-31 18:13
(Received via mailing list)
On 5/31/07, Ari B. <removed_email_address@domain.invalid> 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 }
Avdi G. (Guest)
on 2007-05-31 18:37
(Received via mailing list)
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().
Ari B. (Guest)
on 2007-05-31 23:59
(Received via mailing list)
On May 31, 2007, at 10:12 AM, Felipe C. wrote:

>
> 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.
This topic is locked and can not be replied to.