Login  
Search All Forums
Dart Home | PowerTCP Sockets for .NET | Custom Development Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums   
AuthorForum: PowerTCP Sockets for .NET (Secure and Standard)
Topic: Detect if a client has disconnected from the server
tomsummers40

From: Kaysville, UT USA
Posts: 3
Member Since: 11/26/10
posted January 10, 2014 8:32 PM

I have a server application that runs Dart Sockets version 4.4.0.3. It runs a thread for each client that sends a message.
It runs this:
 protocol.Clone().Start(tcp, ref cd);

After the above runs client closes the connection. I want to detect if the client has closed the connection.
I have tried checking
 tcp.State == Dart.Sockets.ConnectionState.Connected
It always is true even if the client has closed the connection.

How do I detect if the client has closed the connection?

Nick B (Admin)

From: Utica, NY USA
Posts: 583
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted January 13, 2014 10:15 AM

Hello,

The State property returns the connection state at the time of the last read/write operation. A pending read operation is commonly used to determine the current connection state (write can be used as well). The KeepAlive configuration options on Tcp.SocketOption may be used to detect the disconnection sooner during a read/write operation when for instances such as when the cable is disconnected.

------
-Non-current subscribers must contact sales@dart.com to update subscription and receive continued support as needed.
------

tomsummers40

From: Kaysville, UT USA
Posts: 3
Member Since: 11/26/10
posted January 13, 2014 12:43 PM

Thanks for the response.
Could you point me to some sample code of how to use the KeepAlive options to determine if a connection is still open?
Nick B (Admin)

From: Utica, NY USA
Posts: 583
Member Since: 05/25/10

Extra Support Options
Custom Application Development

posted January 13, 2014 3:32 PM

Hello,

I'm sorry, I misspoke in my reply and corrected it. KeepAlives are usually only useful in detecting a disconnection when the cable has been removed, for example, in instances where you have a pending read with no timeout, and the cable is pulled. In every case, a pending read or write is required to detect a changed network status.

------
-Non-current subscribers must contact sales@dart.com to update subscription and receive continued support as needed.
------

Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX