How to set timeout on TCP/IP based client-server connection?

How to set timeout on TCP/IP based client-server connection?

Post by Rich Tsu » Wed, 13 Aug 1997 04:00:00



Hi there,

   Is there any one out there who knows how to set time out for a TCP/IP

based server C program?
Currently my server will hang forever if a client has an inappropriate
exit.
Any comment is very welcome.   Thank you for your time.

Rich Tsui
University of Pittsbrgh

 
 
 

How to set timeout on TCP/IP based client-server connection?

Post by Andrew Giert » Thu, 14 Aug 1997 04:00:00


 Rich> Hi there,
 Rich> Is there any one out there who knows how to set time out for a
 Rich> TCP/IP based server C program?

select() or alarm()?

 Rich> Currently my server will hang forever if a client has an
 Rich> inappropriate exit.

Not good :-)

There are two cases you need to consider:

  - if the client process dies unexpectedly, closing or aborting the
    connection

  - if the client host dies or becomes unreachable

Handling the first case is simply down to correct error handling. The
second case is harder; there's some discussion about it in the Socket FAQ
(http://kipper.york.ac.uk/~vic/sock-faq/)

--
Andrew.

comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>
                           or <URL: http://www.whitefang.com/unix/>

 
 
 

How to set timeout on TCP/IP based client-server connection?

Post by Rich Tsu » Fri, 15 Aug 1997 04:00:00




>  Rich> Hi there,
>  Rich> Is there any one out there who knows how to set time out for a
>  Rich> TCP/IP based server C program?

> select() or alarm()?

Thanks.  I tried select() and it works greatly.

Rich