Networking Forums

Networking Forums > Computer Networking > Linux Networking > Socket programming, detect if client or server has gone away

Reply
Thread Tools Display Modes

Socket programming, detect if client or server has gone away

 
 
Frank de Bot
Guest
Posts: n/a

 
      12-14-2004, 09:18 PM
Hi,

I've written 2 apps in C, a client and a server. But I can't seem to
handle the sudden disconnect of one of the two. According the Socket FAQ
I could get a ECONNRESET from a read if the peer has gone away. How can
I check if the "other side" has gone away or not? (I've already
programmed something with pings, but it doesn't please me)

Thanks in advanced,

Frank de Bot


 
Reply With Quote
 
 
 
 
Jason Stewart
Guest
Posts: n/a

 
      12-21-2004, 01:22 PM
In article <41bf66ac$0$65124$(E-Mail Removed)>, Frank de Bot wrote:
> Hi,
>
> I've written 2 apps in C, a client and a server. But I can't seem to
> handle the sudden disconnect of one of the two. According the Socket FAQ
> I could get a ECONNRESET from a read if the peer has gone away. How can
> I check if the "other side" has gone away or not? (I've already
> programmed something with pings, but it doesn't please me)
>
> Thanks in advanced,
>
> Frank de Bot
>


Hi Frank,

If your application disconnects when no data is actively being sent,
then one side of your app sends data to the other side after the
disconnect, your read call will block until the app gets a reply from
the other side. TCP will retransmit the data up to 12 times over 9
minutes if I recall correctly. After the 9 minutes expires you'll get
ETIMEDOUT.

You'll get ECONNRESET if you lose the connection and then it comes back
up again (physical link broken or server rebooted).

Again, if I recall correctly, The only way to get around the 9 minute
waiting time without setting SO_KEEPALIVE is to use a heartbeat function
where you send data back and forth between clients and if the data is
not received within a specific time frame, assume that the host is down.

Regards,
Jason
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
socket programming rak.dontmess@gmail.com Linux Networking 4 02-12-2008 11:00 PM
Can any one help me!! (Socket Programming) girishdomain@gmail.com Linux Networking 8 05-25-2005 04:17 PM
Connetion reset by peers (Socket Programming) in a Clinet Server Model ???? girishdomain@gmail.com Linux Networking 1 05-25-2005 05:38 AM
socket programming Andreas Lassmann Linux Networking 4 04-27-2005 06:52 AM
socket programming PH Linux Networking 4 11-16-2003 10:39 PM



1 2 3 4 5 6 7 8 9 10 11