Peter Duniho
3/5/2008 6:28:00 PM
On Wed, 05 Mar 2008 02:11:06 -0800, Frederick <frederick.orion@nospam.be>
wrote:
> [...]
> Everything works fine, but now and then my socket server seems to
> crash/hang.
>
> When I check my error-handling I see that my application is throwing this
> exception :
>
> "An existing connection was forcibly closed by the remote host"
>
> [...]
> Someone who can help me or who has experienced the same problem ?
I'm sure lots of people have experienced the same problem. It's not a
very specific description of the problem, and a TCP connection being
closed somehow isn't all that uncommon.
The most common reason this would happen is some problem at the remote
end, either a buggy client, or some issue going on with its network
connection. Depending on the context, it's actually possible you've got a
malicious ISP in the middle sending fake resets. There are all sorts of
reasons this could happen, most of them having nothing to do with the
actual code, but rather something to do with the network.
So, the first step is to fix your server code so that it can reliably and
gracefully handle errors, including this one. Then, if you believe that
the reset connection is a sign of a problem elsewhere, you can move on to
dealing with that.
But you need to be able to handle that error gracefully regardless.
Pete