Re: Other socket stuff
| From: | Sascha Schumann | Date: | Wed, 26 May 1999 17:35:01 +0000 |
| Subject: | Re: Other socket stuff | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-6024@lists.php.net to get a copy of this message | ||
On Wed, May 26, 1999 at 01:08:03PM -0400, Rasmus Lerdorf wrote:
> > 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.
>
> True, perhaps this falls into a more general-purpose user-level select()
> call then. I realize we could implement this internally and hide the
> functionality from the user, but there have been requests for the ability
> to open up multiple sockets and be able to asynchronously manage them. I
> don't really want to get into asynchronous events here, but something
> like:
>
> $s1 = fsockopen(...);
> $s2 = fsockopen(...);
> $ret = select(array($s1,$s2),3); // 3-second timeout
> echo "$ret responded first";
>
> might do the trick. If the first argument is not an array, it could be
> assumed that it is just a single descriptor.
Well, that would make things much more complicated. We basically would need to
open up the whole POSIX magic box and provide a nice and clean interface to it
(as far that is possible at all) from the PHP user level.
So, initially, we have two options (complementary)
(a) provide all the socket stuff to the end user (this could be extended later
to the whole POSIX API)
(b) extend fsockopen to allow setting a timeout
The later one could be done in reasonable time (in fact, I have code for
connect_nonb C function here).
The former one is even more appealing to me. Once we would have a complete
POSIX module (thinking of Perl here), the end-user could do almost everything
as he could do with regular C code (function-wise, speed is another issue).
--
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