Re: how to handle socket timeout?



On Jan 15, 11:03 am, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:

Why does it matter what you do in this case? The server is
unreachable. Nothing will work. It doesn't matter what you do or try
to do to the connection. There will be no response, so you will have
no response to give. You can give up waiting whenever you want, but
with respect to the connection, what you send, and what you detect, it
doesn't matter.

It does for me. I want to start attempts to reconnect, in a different
thread, through the configurable interval of time. Once the server
stops being unreachable, the connect will succeed, and I will have
connections in my pool, ready to use. Until then, all my requests
immediately return failure since there is no available connections.
But, once the server stops being unreachable, the requests start
succeeding.

I think this model allows me to achieve the goal of "fast result or no
result". The notion of "fast" is configurable by the timeout value.

Let's say I setup all the facility on the LAN, and the server's
average response time is 0.1 msec. If I set the timeout to, for
example, 1 msec, everything will go smoothly most of the time. When I
get a timeout, this may mean one of a few things:

1) The server became unreachable. I want to close the socket and
start attempts to reconnect;

2) Accidentially long response. Still nothing wrong with
reconnecting, since this happens rearly (how rarely -- can be
controlled by the value of the timeout);

3) Server is congested. This is the worst case. But, IMO, this is
the case where nothing can be done. Except adding another server
instance to split the load.

4) Network is congested. Again, I don't see what can be done in this
case.

So it seems to me that reconnect works OK for both cases where
anything can be done -- I just need to setup reasonably large timeout
-- sufficiently larger than the average response time under normal
conditions. For two other cases, it seems yes, I am adding a bit to
already existing mess. But does this really matter?

Am I missing something?

Regards,
Arkadiy
.



Relevant Pages

  • Re: Is yahoo being hijacked?
    ... I get no server response when query ... > Connection: close ...
    (misc.invest.stocks)
  • Is yahoo being hijacked?
    ... I get no server response when query ... The server returned the following response headers: ... Connection: close ...
    (misc.invest.stocks)
  • Re: Is yahoo being hijacked?
    ... I get no server response when query ... > Connection: close ...
    (misc.invest.stocks)
  • Re: Is yahoo being hijacked?
    ... I get no server response when query ... > Connection: close ...
    (misc.invest.stocks)
  • Re: web serivce: client side timeout?
    ... client side but only from the server side. ... System.Net.Sockets.SocketException: A connection attempt failed ... asyncResult, Int32 timeout, Exception& exception) ... John Saunders | MVP - Windows Server System - Connected System ...
    (microsoft.public.dotnet.framework.webservices)