HOW TO DETECT TCP/IP CABLE DISCONNECTION

Hi Everybody

Have a problem in a simple TCP/IP app. My app is running as a passive server listening and accepting a TCP connexion.
The connexion is stablish and works well but I want to detect when the it goes down because of a cable disconnection.

I’ve been testing tcp-tick and socket-alive to see if they return 0 (zero) when the cable disconnect, but it seems that this mechanism doesn’ t work. The socket continues establish, and tcp-tick returns 6.

So I guess that the tcp stack doesn’t realize that the cable was disconnected. Is there any mechanism to detect when the other side is not there anymore??

Do anybody know how to detect this situation??? Because I need to go and listening again for a new tcp connection.

I guess that if the application on the other socket side goes down without closing the socket, the situation would be the same.

I’ m using a rabbit 3700 and dynamic c 9,6

BR, Gustavo

Hi,
try this:
.
.
fEth = FALSE;
.
.
while(1){
[indent] loophead();
.
.
costate{
[indent] tcp_tick(NULL);
if(!pd_havelink(IF_DEFAULT) && fEth){
[indent] dhcp_release();
fEth = FALSE;
}
if(pd_havelink(IF_DEFAULT) && !fEth){
dhcp_acquire();
fEth = TRUE;
}
}[/indent] [/indent]
.
.
} [/indent]

fEth == true when connected, false otherwise,

This works just fine for us.
Cheers,
Martin

Hi Martin

Thanks for your reply.
I’ll test it

I didn’t know about pd_ functions.
There’s lot of functions to learn and it’ s difficult to manage all of them when your’ re not all the day with this kind of developments

BR, Gustavo