and man 7 socket
It is possible to do non-blocking IO on sockets by setting the O_NON- BLOCK flag on a socket file descriptor using fcntl(2). Then all opera- tions that would block will (usually) return with EAGAIN (operation should be retried later); connect(2) will return EINPROGRESS error. The user can then wait for various events via poll(2) or select(2).
[august]->[Re: [PD-dev] socket gurus]->[04-03-02 16:39]
| |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); | | | | |_______________________________________________ |PD-dev mailing list |PD-dev@iem.at |http://iem.at/cgi-bin/mailman/listinfo/pd-dev |