From: Randy General Date: 2009-07-09T02:12:45+09:00 Subject: Re: How to accept a varying amount of UDP packets using recvfrom Bill Kelly wrote: > > Generally, use select to specifiy the desired timeout. > > However, it's a little more complicated with ruby and UDP, such > that one may end up needing to wrap the recvfrom in a > timeout { } block anyway. (On some operating systems, if the > UDP packet has a checksum error, select can return ready, > but recvfrom will block. (And in many (all?) versions of ruby, > setting fcntl O_NONBLOCK does not help due to ruby's > internals.)) > > This rubyforge project has code for receiving one-or-more UDP > packets from a Quake2 server: > > http://rubyforge.org/scm/?group_id=288 > > The relevant source file is: dorkbuster/dbcore/q2rcon.rb > > Here's the innermost receive method: http://pastebin.com/f716b381d > > > Hope this helps, > > Bill Thanks for your replies! The code in that pastie is a bit beyond my current skill level (just began programming a few days ago), but I'll see if I can make some sense of it and incorporate it into my own app. Thanks for your help! -- Posted via http://www.ruby-forum.com/.