Jon Fi wrote:

> Hello... I am writing a simple chat program, but i have encountered a
> problem. I ask for a client to provide a handle, but it he disconnects
> during a gets call, it does weird things.

/...

> If the client disconnects at this point, ruby seems to be still waiting
> for a response. Also, sometimes it sends ruby's processor usage to 100%.
> 
> Is there a better way to do this? Or is there a way to give gets a
> timeout? Thanks!

IO#gets blocks forever if the input goes away, while IO#readline throws an
exception on EOF. I think your situation qualifies as an EOF. Why not try
it?

-- 
Paul Lutus
http://www.arachnoid.com