[PD-dev] socket gurus

august august at alien.mur.at
Tue Mar 2 16:39:11 CET 2004


On Tue, 2 Mar 2004, Tom Schouten wrote:
> hi august,
> check man 2 connect:
>        ETIMEDOUT
>               Timeout  while attempting connection. The server may be too
>               busy to accept new connections. Note that
>               for IP sockets the timeout may be very long when syncookies
>               are enabled on the server.
> so you're better off using select, then you can set your own timeout.
> tom

Tom,

I don't even make it that far.  Connect() doesn't return anything!
I can't even get an error response.  And without a connection, select does
me no good.

Doing a search, I saw some ppl using alarm and signal around the connect
call to kill it if it hangs.  This looks like a dirty hack though.  Any
comments?  code below.

-august.


    signal (SIGALRM, connect_timed_out);
    alarm (CONNECT_TIME_OUT);
    
    if(connect(sock,(struct sockadr *)& server,sizeof(server))<0)
    {
 perror("connect");
 exit(1);
    }
    
    /**
     ** Just in case the other end crashes without closing
     ** and we hang on a write
     ** time out the whole program after a while 
     **/
    
    alarm (NORMAL_TIME_OUT);
    signal (SIGALRM, normal_time_out);







More information about the Pd-dev mailing list