Linux TCP Socket Disconnection Question

Just starting out? Need help? Post your questions and find answers here.
swhite
Enthusiast
Enthusiast
Posts: 726
Joined: Thu May 21, 2009 6:56 pm

Linux TCP Socket Disconnection Question

Post by swhite »

I have a scenario where a network cable can become disconnected from a device. If the cable is re-connected before the watch dog timer on the device fires communication with the device will resume. However, if the connection is made after the watch dog timer has closed the connection then communication will not resume. In Purebasic I cannot detect this scenario and when I try communicating after the network connection is closed by the watch dog timer my Linux application exits without any error message. I assume that has something to do with the network connection not being valid anymore. I would have thought it would have thrown an
error but instead the application just exits.

Does anyone have any suggestions about how this could be handled so the application does not just exit without calling the error routine.

Thanks,
Simon
Simon White
dCipher Computing
swhite
Enthusiast
Enthusiast
Posts: 726
Joined: Thu May 21, 2009 6:56 pm

Solved: Linux TCP Socket Disconnection Question

Post by swhite »

Hi

It turns out that the code reading the data from the connection was failing to check for the #PB_NetworkEvent_Disconnect. Once this was corrected the code worked properly and detected the closed connection.

Simon
Simon White
dCipher Computing
User avatar
mk-soft
Always Here
Always Here
Posts: 5335
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Linux TCP Socket Disconnection Question

Post by mk-soft »

The event "#PB_NetworkEvent_Disconnect" cannot be used to reliably detect a technical fault in the network.

As a rule, with your own protocols, you programme a life trigger and your own timeout in the server for the connected clients.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply