Problem disconnecting .NET TCP client

Posted on 2014-08-09
Last Modified: 2014-08-10
Hello, here's my code to disconnect a TCP client connected to a TCP server:

    Public Function Disconnect() As Boolean

        ptr_ClientSocket.BeginDisconnect(True, New AsyncCallback(AddressOf DisconnectCallback), Nothing)

        Return True

    End Function

    Private Sub DisconnectCallback(ByVal ar As IAsyncResult)


    End Sub

Open in new window

The weird part is that my DisconnectCallback never fires, and it stalls in 'Disconnecting' state.  Does this require some action on the server side?  What's the right way to do this?

Thanks for any help.
Question by:RonMexico
    1 Comment
    LVL 77

    Accepted Solution


    is how I deal with it also on the server you should have a sort of a heartbeat that checks the client connection status by sending 1 byte if it fails then the client is disconnected otherwise it is connected.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now