Problem with permanent socket connection

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I want to open a permanent socket connection to a service witch is running
on the same computer.
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 ?

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.

Thanx for Help

Re: Problem with permanent socket connection

On Tue, 02 May 2006 13:38:59 +0200, Ismail Demiralp wrote:
Quoted text here. Click to load it

Write a daemon that opens this socket, then pass commands to the daemon
(maybe by signals, maybe using a socket) from PHP.

Quoted text here. Click to load it

Have you read the comments on

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_.



Andy Jeffries MBCS CITP ZCE   | gPHPEdit Lead Developer | PHP editor for Gnome 2 | Personal site and photos

Site Timeline