NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP AND AOL Instant Messenger

Dan Cech dcech at phpwerx.net
Fri Oct 1 09:28:14 EDT 2004


Joseph Crawford wrote:
> I figured i would ask this here since there is not much for
> documentation i have found on the web.
> 
> When you create a socket connection in PHP, will it carry from page to
> page or will you have to reconnect the socket everytime?

You would have to reopen the socket on each page.

> I was thinking of implementing an AOL IM from a web page that will
> allow you to sign on and send IM's from the site, however i either
> need to keep the main window open and figure out some way not to close
> the socket until they click logoff and open all IM windows as new
> windows.  Or i need to be ablet o have the connection stay between
> page calls.

There are a few different possibilities, depending on the system you 
want to run it on.

In any case to do this through php you would most likely have to have a 
background server process running for each IM session (this can just be 
a php script), which would maintain the socket and do the actual 
communication.

Your frontend would then pass any user inputs to the server process and 
read the output for display.

One way to set this up would be to use proc_open 
(http://php.net/proc_open) to launch the server process with both its 
input and output redirected to files.  Then when someone sends an IM 
you send the command to the input file, the server process does the 
communication and it writes the result to the output file.

Your script to display the conversation just grabs output from the 
output file.

I haven't tried to build a system like this myself, but in theory I 
think it should work.

Another possibility is to use a database to communicate between the 
frontend and the server process, but it would probably be too slow for 
your purposes.

Dan

> If anyone has any links that could be helpfull i would appreciate it,
> all i have been able to find is this
> 
> http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_20450773.html
> 



More information about the talk mailing list