On Fri, 2008-04-11 at 10:14 -0300, Rodrigo Reis da Rocha wrote:
> I want to make an persistent connection via ssh2 to a server with php, but
> all I can get with the present API is an temporary connection that is lost
> at end of the script.
> Anyone have an idea of how I can save the Resource and reuse it on future
> scripts instead of having to reconnect over and over again?

Hi Rodrigo

I recently did a little app that maintained persistent connections to a
XMPP server - a similar solution should apply to your problem.

I built a memory-resident app in the middle that received a unique ID
from my PHP page (you could use session_id for instance), assigned that
ID to a connection and created a permanent connection. It also queued
incoming messages so that when the PHP script connected again, it could
send through the queued messages, so that the end-user didn't miss
anything.

Initially I tried using PHP-cli for the memory-resident app but
eventually settled on Twistd Python because it was better at running
resident and handling multiple connections from different users without
blocking anything. On the front-end I used PHP and Ajax to give a
feeling of a "live" connection.

J


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to