Socket closed causes problems

  • Thread starter Thread starter hermbagger
  • Start date Start date
H

hermbagger

I have an async socket server running. When a connected client closes
the connection, the servers' OnDataReceived function seems to get
bombarded with empty messages (0 bytes) It causes the entire server
to hang until an exception is thrown and the socket gets released.
How can I handle this situation? No method of checking for message
length or message content seems to be able to kill the connection in
time because the bombardment is so rapid.

Has anyone else had this problem?
 
Actually, I just had the same thing happen in the client when I closed the
server. I tried checking for theSockId.thisSocket.Connected but it
continues to return "true". I am able to check the value of
theSockId.thisSocket.EndReceive(asny) and if it's 0 I can close but this
doesn't seem like a very elegant way to determine if a connection was
closed.

If anyone has some insight on this, it sure would be appreciated.

sr
 
Back
Top