Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Detecting a connection loss && other network questions

Thread Tools

Detecting a connection loss && other network questions

David Leal
Posts: n/a
Hello all,

I'm trying to get acquainted with network programming in Ruby and I'm
facing several problems. The biggest 2 are

1) How do I detect a connection loss when it happens while the client is
blocking, waiting for data? According to Stevens, most tcp
implementations time out after 11 minutes, but I disconnected my cable
and waited long after that--nothing. Is this my fault? Is it a ruby

2) The client (an IRC bot) seems to be stuck sometimes. Suddenly, input
stops, it stops logging data, everything stops. This happens on a
particular IRC server ( in the middle of the MOTD,
but happened a few days ago on another server during normal usage. The
code I'm using is

buffer = @socket.recvfrom(512).first
messages = buffer.split /\n/

@messages.last << messages.shift \
if @messages.last && @messages.last[-1] != ?\r

@messages += messages

An interesting twist is that this doesn't happen on heinlein upon
connection if I print the contents of the array I get from recvfrom.
Seems to be some kind of flushing problem, but I don't know enough about
it to be sure.

Any ideas?


Posted via

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
No "Wireless Network Connection" available in network connection =?Utf-8?B?am9raW5kYTE=?= Wireless Networking 7 10-16-2012 07:32 AM
Wireless connection of notebook causes internet loss on other network machine..! Don Draks Wireless Networking 1 09-18-2005 10:02 PM
Detecting loss of session Chris ASP .Net 4 08-25-2004 01:52 PM
Re: connection loss every 5 minutes francis.gerard Wireless Networking 0 07-27-2004 06:22 PM
JPEG Questions: Loss In Quality When "Saving" Xtx99 Digital Photography 14 04-13-2004 03:09 PM