Re: how to handle socket timeout?
- From: Rainer Weikusat <rweikusat@xxxxxxxxxxx>
- Date: Tue, 15 Jan 2008 18:47:51 +0100
Arkadiy <vertleyb@xxxxxxxxx> writes:
On Jan 15, 11:03 am, David Schwartz <dav...@xxxxxxxxxxxxx> wrote:
[...]
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;
This will result in a FIN being transmitted to the server, after which
the kernel waits for a FIN-ACK coming from there and sends an ACK. If
the server is unreachable, this will not work, and if it is just
responding slowly, your close request will be processed after all
other requests you have sent and the connection will be closed after
you have processed all replies to these requests (this is the default
behaviour, hackarounds would be possible).
2) Accidentially long response. Still nothing wrong with
reconnecting, since this happens rearly (how rarely -- can be
controlled by the value of the timeout);
This is actually situation 3: The server cannot reply fast enough.
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.
The easy thing which could be done is to not increase the load in the
server by torturing it with completely useless connection teardown and
re-establishment requests.
4) Network is congested. Again, I don't see what can be done in this
case.
Same as above. Avoid injecting more useless packets.
To repeat this again: TCP is a reliable bytestream protocol based on
persistent virtual circuits. Either you want a reliable bytestream
protocol, then you should just be using it, or you don't want a
reliable bytestream protocol and then don't use it.
For practical purposes, the daemon you are talking to is closely
similar to a network file system server and the way you want to use it
would lend itself to the 'traditional' way NFS worked: Assume the
server is stateless (gets around all possible issues with crashes
etc), send a request using UDP when you want to request some data,
possibly, retransmit that a couple of times using a 'standard'
exponential backoff algorithm and process eventual replies when and if
they arrive, dropping whatever you don't want anymore.
This is exactly the same procedure one would sensibly use for TCP,
except that it is not necessary to deal with connections anymore.
[...]
Am I missing something?
An introduction in internetworking protocols, maybe?
.
- References:
- how to handle socket timeout?
- From: Arkadiy
- Re: how to handle socket timeout?
- From: Arkadiy
- Re: how to handle socket timeout?
- From: Rainer Weikusat
- Re: how to handle socket timeout?
- From: Arkadiy
- Re: how to handle socket timeout?
- From: Rainer Weikusat
- Re: how to handle socket timeout?
- From: Arkadiy
- Re: how to handle socket timeout?
- From: Rick Jones
- Re: how to handle socket timeout?
- From: Rick Jones
- Re: how to handle socket timeout?
- From: Arkadiy
- Re: how to handle socket timeout?
- From: David Schwartz
- Re: how to handle socket timeout?
- From: Arkadiy
- Re: how to handle socket timeout?
- From: David Schwartz
- Re: how to handle socket timeout?
- From: Arkadiy
- Re: how to handle socket timeout?
- From: David Schwartz
- Re: how to handle socket timeout?
- From: Arkadiy
- how to handle socket timeout?
- Prev by Date: Re: how to handle socket timeout?
- Next by Date: Re: how to handle socket timeout?
- Previous by thread: Re: how to handle socket timeout?
- Next by thread: Re: how to handle socket timeout?
- Index(es):
Relevant Pages
|