CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2005
    Posts
    99

    Detect lost connection to peer

    I've been experimenting with the using System.Net.Sockets.Socket class for .Net 2.0 in Visual Studio 2005.
    I have a server application that accepts TCP connections from client machines. The software that the clients are using is not ours so we can't use any handshaking communications. I want to be able to detect if the network cable connecting the client machine to the network gets disconnected. I first tried the Poll method, but it didn't work. The MSDN actually stated that Poll cannot be used for detecting Network cable failures, and instead to try sending/receiving. Since the server application is ours I added code to send out a small message to the client socket every 5 seconds. I figured once I pulled the network cable at the client machine, the send would throw an exception and I would be able to catch the event. However the send kept sending with no problems at the server end. I already have a thread that performs a receive attempt on the client socket to read in client messages, and that code continues to run as well with no exceptions.
    That leaves me kind of stuck. I read in another post about setting up a KEEP_ALIVE option on the socket, but the minimum wait time is 2 hours, which is too long to detect that the client connection is lost.
    I'm wondering if anyone else ran into this problem in .Net and found a solution?

  2. #2
    Join Date
    Mar 2005
    Posts
    99

    Re: Detect lost connection to peer

    Still wondering about this issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured