Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Socket timeout

Reply
Thread Tools

Socket timeout

 
 
Lee Jarvis
Guest
Posts: n/a
 
      11-12-2007
I am using a TCPSocket and I want the script to restart if the
connection times out. I have tried doing it myself and searched around
everywhere for a solution but I have had no luck.. Any help would be
great

tia

Lee
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Francis Cianfrocca
Guest
Posts: n/a
 
      11-12-2007
Note: parts of this message were removed by the gateway to make it a legal Usenet post.

On 11/11/07, Lee Jarvis <> wrote:
>
> I am using a TCPSocket and I want the script to restart if the
> connection times out. I have tried doing it myself and searched around
> everywhere for a solution but I have had no luck.. Any help would be
> great




What do you mean by "the connection times out"? Do you mean that the
connection has no read or write activity for some interval of time?

If you need to do that, then the Ruby/EventMachine library has that ability.
You'll need to rearrange your code to go this route, so perhaps someone else
will have a less invasive solution. If not, then look at EventMachine.

 
Reply With Quote
 
 
 
 
Lee Jarvis
Guest
Posts: n/a
 
      11-12-2007
Francis Cianfrocca wrote:
> What do you mean by "the connection times out"? Do you mean that the
> connection has no read or write activity for some interval of time?

Yes, basically


> If you need to do that, then the Ruby/EventMachine library has that
> ability.
> You'll need to rearrange your code to go this route, so perhaps someone
> else
> will have a less invasive solution. If not, then look at EventMachine.


Uh, I am editing an old program of mine which is quite large, about
1.4k+ lines, so I am trying to do it the least invasive way possible.. I
appreciate your input so quickly though. Perhaps this is the only route.

Lee
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Yohanes Santoso
Guest
Posts: n/a
 
      11-12-2007
Lee Jarvis <> writes:

Q> Francis Cianfrocca wrote:
>> What do you mean by "the connection times out"? Do you mean that the
>> connection has no read or write activity for some interval of time?

> Yes, basically



You can adjust the SO_RCVTIMEO and SO_SNDTIMEO socket options using
Socket#{get,set}sockopts.

However, they are susceptible to trickle attack. For example, if you
set the receive timeout to 30 seconds, then the sender can send just
one packet every 30 seconds, tying up resources on your end.

The proper solution requires application-level enforcement of
timeout. You can use the timeout library for the least invasive
mechanism to even changing the core mechanism to Ruby/EventMachine.


YS.



>
>
>> If you need to do that, then the Ruby/EventMachine library has that
>> ability.
>> You'll need to rearrange your code to go this route, so perhaps someone
>> else
>> will have a less invasive solution. If not, then look at EventMachine.

>
> Uh, I am editing an old program of mine which is quite large, about
> 1.4k+ lines, so I am trying to do it the least invasive way possible.. I
> appreciate your input so quickly though. Perhaps this is the only route.
>
> Lee
> --
> Posted via http://www.ruby-forum.com/.


 
Reply With Quote
 
Roger Pack
Guest
Posts: n/a
 
      11-12-2007
If you're not worried about scaling then
Timeout::timeout(30) {
do stuff }

or
Thread.new {
sleep 30
if hasnt_done_anything
raise on it # scary!
end
}

maybe

Lee Jarvis wrote:
> I am using a TCPSocket and I want the script to restart if the
> connection times out. I have tried doing it myself and searched around
> everywhere for a solution but I have had no luck.. Any help would be
> great
>
> tia
>
> Lee


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

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
Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 0 02-01-2009 07:37 AM
socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use') Laszlo Nagy Python 1 01-27-2009 05:05 PM
Re: socket.unbind or socket.unlisten? - socket.error: (48,'Address already in use') Jean-Paul Calderone Python 0 01-27-2009 01:41 PM
download timeout vs. socket timeout p. Python 4 01-10-2009 07:39 PM
Timeout::timeout and Socket timeout Mark Probert Ruby 1 10-06-2004 09:30 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57