You might also try enabling the keep alive socket option, which will add to
the amount of network traffic a socket will cause, but also tends to allow
the socket to notice that it is no longer connected a little faster than any
other method. You've discovered part of the wonders of socket programming,
which is that if something happens in the network level, it can be difficult
to determine if a socket is really still connected or not.
Ryan Gregg
"alien" <alien@sympatico.ca> wrote in message
news:ZjCmc.44017$3Q4.1057579@news20.bellglobal.com ...[color=blue]
> try the Poll method
> "Frank Meng" <mengfrank@hotmail.com> wrote in message
> news:1a370138.0405061803.1948db49@posting.google.c om...[color=green]
> > Hi.
> > I am trying a csharp sample from
> >
http://www.codeproject.com/csharp/socketsincs.asp .
> > (Sorry I didn't post all the source codes here, please get the codes
> > from above link if you want to try).
> > I had some troubles when I started 6 threads (each thread made a
> > separate connection) and sent messages to same server simultaneously.
> > Sometimes, not always, the socket looks like ok, but really it is
> > dead.
> > I don't why it happens.
> > If I can't fix this problem, I want to detect if the connection is
> > dead.
> > if( m_sock == null || !m_sock.Connected )
> > return false, that mean the client thinks it IS connected to the
> > server.
> > But after I sent the message, the server didn't receive anything.
> > After that, it will never work again, unless the client reconnects the
> > server.
> > I can't disconnect the connection after I sent my message, because I
> > want to hear the response from the server.
> > If the client can detect the real connection status, the client can
> > reconnect to the server when the connection is dead.
> > How do I detect the real status of a socket?
> >
> > Frank[/color]
>
>[/color]