|
Posted by Andy Jeffries on 11/21/69 11:46
On Tue, 02 May 2006 13:38:59 +0200, Ismail Demiralp wrote:
> After I logged in on my php page, I start a session. After this a socket
> connection should be opened to a service I get data from. Now my problem
> is I want open only once a socket connection to the service and after this
> I want use on all php pages this connection. How can I transmit (or use)
> this one connection on all pages ?
Write a daemon that opens this socket, then pass commands to the daemon
(maybe by signals, maybe using a socket) from PHP.
> I opened the socket connection like this:
>
> $fp = pfsockopen ($url, 1006, $errno, $errstr, 10);
>
> This code snippet is running correctly, but on the next php page I can't
> use this connection.
Have you read the comments on php.net:
http://uk2.php.net/pfsockopen
OK, WRT to the p* functions opening a new connection when one already
exists. It is my understanting that (under Apache anyways) this is on a
per-process basis. If you do a 'ps auxw|grep httpd' on your server you
will see more than one process. What p* does is make a p-connection on one
of those processes only, the one that actually handles your request.
Chances are that when you hit the page again it will be answered by a
different process. I'm guessing if you keep hitting reload you'll get
around to the original process again and there will be no error message or
second connection open. Anyhow, this is true of all p* functions; they
open not one connection per server, but one connection per server _process_.
Cheers,
Andy
--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos
Navigation:
[Reply to this message]
|