Socket.Send Exception Delay

C

CKane

i am trying to build a "missed message" queue on a C# TCP server. many
of the devices connecting are mobile and may drop out in bad signal
areas. i want to store any messages missed for when they reconnect.

so far....it takes activity on the client end to initialize the close.
isnt there a check when the server sends a socket.send to a client that
has lost connection? it takes a few minutes for the exception to get
hit, and i am losing vital time.

is there a way for as soon as the the server attempts Socket.Send it
can tell if the device on the other end still has an active connection?

even Socket.Poll() has quite a delay.

i have been testing with desktops. I connect two workstations to the
server and when i chat back and forth, i unplug one from the network.
it takes at least two minutes for the server to recognize that one
client is disconnected while the still-connected client is sending
messages. it seems they are just going nowhere.
 
D

Derrick Coetzee [MSFT]

CKane said:
so far....it takes activity on the client end to initialize the close.
isnt there a check when the server sends a socket.send to a client
that has lost connection? it takes a few minutes for the exception to
get hit, and i am losing vital time.
[...]
i have been testing with desktops. I connect two workstations to the
server and when i chat back and forth, i unplug one from the network.
it takes at least two minutes for the server to recognize that one
client is disconnected while the still-connected client is sending
messages. it seems they are just going nowhere.

Hi CKane. This is an inherent issue with the TCP protocol, and perhaps
transport protocols in general - it is able to maintain a session, but if
one client just "drops out" with no close message, it is impossible to
distinguish this from a temporary spike in latency or other network
problems. Your best bet is to set up some kind of application-level "ping"
message that is sent periodically between the client and server to
continually verify that the client is present - if you receive no response
for a certain number of pings, you can use this to guess that the client has
dropped. Just ensure that if they didn't drop after all that nothing
terrible happens and you can recover. I hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top