[Ruby] ?????? ?? ?????? ??????????????? ?????????? ?????

Podborits, Dmitry dpodbori at lehman.com
Wed May 7 19:14:24 MSD 2003


Вот Сервер строки нагоняет 
Подул, завыл, и вот ЕОФ 
Уже летит поверх голов 
Хоть ничего не возвращает 

Клиент из цикла повалился 
Из сокета тяня строку, 
И, лежа в луже на боку, 
Без блокировки отрубился. 

-----Original Message-----
From: Yuri Leikind [mailto:y.leikind at sam-solutions.net] 
Sent: Wednesday, May 07, 2003 11:04 AM
To: ruby at altlinux.ru
Subject: Re: [Ruby] ?????? ?? ?????? ??????????????? ?????????? ?????


On Wed, 7 May 2003 20:47:05 +0600
vic ismakaev <viclists at mail.esoo.ru> wrote:

> 7 Май 2003 19:55, Ihar Viarheichyk написал:
> > On Wed, May 07, 2003 at 07:10:15PM +0600, vic ismakaev wrote:
> > > сервер> пишет строку в сокет
> > > клиент> читает строку и что-то с ней делает
> > > сервер> не пишет строку в сокет(ничего не шлет)
> > > клиент> вывалится из цикла
> > > <конец цикла>
> > >
> > > Насколько я понял - надо пользоваться неблокирующим чтением 
> > > сокета.Но как это сделать - не пойму.:(
> >
> > Дык, Kernel#select.
> Похоже оно.
> Но не пойму,как это применить.


3 апреля Игорь Вергейчик в ответ на Ваше письмо уже привел пример
использования select, это поможет Вам и на этот раз


> По идее
> a=[]
> select([@socket],a,nil,0.1)
> должна считать все в массив a.Но не считывает :(  Где-то я косячу.

Значит возвращается nil. select лучше в циклах использовать


leikind at pc324:~$ ri Kernel#select
--------------------------------------------------------- Kernel::select
     select( readArray [, writeArray [errorArray [timeout]]] ) ->
     anArray or nil
------------------------------------------------------------------------
     Performs a low-level select call, which waits for data to become
     available from input/output devices. The first three parameters are
     arrays of IO objects or nil. The last is a timeout in seconds,
     which should be an Integer or a Float. The call waits for data to
     become available for any of the IO objects in readArray, for
     buffers to have cleared sufficiently to enable writing to any of
     the devices in writeArray, or for an error to occur on the devices
     in errorArray. If one or more of these conditions are met, the call
     returns a three-element array containing arrays of the IO objects
     that were ready. Otherwise, if there is no change in status for
     timeout seconds, the call returns nil. If all parameters are nil,
     the current thread sleeps forever.
        select( [$stdin], nil, nil, 1.5 )   #=> [[#<IO:0x4019202c>], [],
[]]



> 
> --
> С уважением
> Виктор В Исмакаев
>                                                
> Ruby mailing list
> Ruby at altlinux.ru
> http://www.altlinux.ru/mailman/listinfo/ruby


-- 
Best regards,
Yuri Leikind


"... 5 years from now everyone will be running free 
GNU on their 200 MIPS, 64M SPARCstation-5."

Andy Tanenbaum to Linus Torvalds 
in comp.lang.minix on Jan 1, 1992
http://groups.google.com/groups?lr=&selm=12615%40star.cs.vu.nl
                                               
Ruby mailing list
Ruby at altlinux.ru
http://www.altlinux.ru/mailman/listinfo/ruby


------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the designated recipient(s) named above.  If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited.  This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers.  Email transmission cannot be guaranteed to be secure or error-free.  Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such.  All information is subject to change without notice.





More information about the Ruby mailing list