Re: Connection Timeout

From: Bjorn Reese (breese_at_see.signature)
Date: 06/26/04


Date: Sat, 26 Jun 2004 15:29:46 +0200

On Sat, 26 Jun 2004 02:59:05 -0700, Michal J wrote:

> can this func return CODE_ERR_TIMEOUT after 10 sec timeout ??

There are two possibilities.

1. Use alrm(). Set alrm(10) before the connect call, and alrm(0)
   afterwards. A timeout is detected by connect() returning -1
   and errno set to EINTR. This solution does not work in multi-
   threaded applications.

2. Use non-blocking sockets, and wait the 10 seconds in a select
   call. This solution is more involving. See for example

     http://www.kegel.com/dkftpbench/nonblocking.html

-- 
mail1dotstofanetdotdk