Re: Other socket stuff

From: Date: Wed, 26 May 1999 16:58:28 +0000
Subject: Re: Other socket stuff
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-6022@lists.php.net to get a copy of this message
On Wed, May 26, 1999 at 11:08:05AM -0400, Rasmus Lerdorf wrote: > Sascha, you are speeding along at an amazing pace on this stuff! Since I > don't want to risk you running out of things to do, I have something on my > TODO list here that I have been avoiding. ;) How kind of you. :) > > It would be extremely handy if the various network-related functions could > be timed out on their initial socket connection. Once connected, you can > toss the connection into non-blocking mode and timeouts aren't an issue. > But you can't do a non-blocking initial connect. Well, one can do nonblocking connects. When a TCP socket is set nonblocking and then connect is called, connect returns immediately with an error of EINPROGRESS but the TCP three-way handshake continues. We then check for either a successful or unsuccessful completion of the connection establishment using select. The described technique avoids the problem with borrowing Apache's reserved signal. > The obvious solution is to use an alarm() call and somehow let the user > specify a timeout to feed to this call. Then catch SIGALRM. The one > slight problem here is that Apache uses SIGALRM and this has been the main > reason this hasn't been implemented. Apache 2.0 is unlikely to eat up > SIGALRM on us, and after a bit of testing, I think we can actually use > SIGALRM even with Apache-1.3.x. It wouldn't be super-safe, and in a > worst-case scenario, things might go wrong, but in 99.9% of the cases it > should be safe to temporarily grab SIGALRM for the purposes of a connect > and then restore the Apache handler afterwards. > > What are your thoughts on this? We should reserve ALRM for other things. I think it would be a great improvement, if a user could time out all functions. That could be efficiently implemented using alarm(2). -- Regards, Sascha Schumann Consultant -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#6022) next »