V
Valerie Hough
I have a process which accepts multiple asynchronous TCP socket connections.
Periodically I want this task to check for abnormal disconnection by each
client. The code that detects this correctly is:
if (( socket.Poll( 1, SelectMode.Read )) &&
( socket.Available == 0 ))
{
// abnormal disconnect
}
but this periodically seems to detect a failure when the socket is still
working correctly (perhaps the wait period
of 1 is too short?)
also, the documentation infers this should work:
if ( socket.Poll( 1, SelectMode.Error ))
{
// error
}
Q1: What's the deal with SelectMode.Error - why does it not detect an error?
Is abnormally disconnected not an error?
Q2: What happens when the interval specified (i.e. 1 in the first example)
elapses without getting a result; does this generate an exception or return
an error?
Q3: Is there a foolproof way of detecting that a socket is no longer going
to work?
TIA
Chris Hough
Periodically I want this task to check for abnormal disconnection by each
client. The code that detects this correctly is:
if (( socket.Poll( 1, SelectMode.Read )) &&
( socket.Available == 0 ))
{
// abnormal disconnect
}
but this periodically seems to detect a failure when the socket is still
working correctly (perhaps the wait period
of 1 is too short?)
also, the documentation infers this should work:
if ( socket.Poll( 1, SelectMode.Error ))
{
// error
}
Q1: What's the deal with SelectMode.Error - why does it not detect an error?
Is abnormally disconnected not an error?
Q2: What happens when the interval specified (i.e. 1 in the first example)
elapses without getting a result; does this generate an exception or return
an error?
Q3: Is there a foolproof way of detecting that a socket is no longer going
to work?
TIA
Chris Hough