NYCPHP Meetup

[nycphp-talk] Re: IM App

Mark Armendariz nyphp at enobrev.com
Sat Aug 9 17:22:18 EDT 2003


A few months ago, I created a php based socket server app (based in part
on http://www.php-tools.de/site.php socket server class).  For the front
end, I used flash via xml_sockets.  Now in order to add IM-ability to
the chat app, I basically set allow the user to click on a user who is
logged on which will send an "IM" command to the server via the socket,
which in turn sends it to that user via their socket connection.  Then
Using javascript from Flash it open up a new browser window with a new
room with the two members in it for both clients.

Most everything is held in php arrays and the class is continually open
on the server (with a while (1) { // socket commands }).  The only issue
I had was that my hosts's server wouldn't allow the app to run
constantly, so the socket connections would close after 20 minutes.  Now
that they just gave me my own server, I may be able to keep it running
at all times.

I've also done something similar with perl before that, which worked
well, but I've never liked maintaining perl because I'm not strong
enough with it.

I've found that the traffic and processees involved are incredibly
minimal, but it's only been for a group of 30 of us at a time.  The app
also adds all messages to a mysql database for archiving, and besides
the time limit which I'll be working around now, I've had no problems.

Good luck!

Mark

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
On Behalf Of Larry Velez
Sent: Thursday, August 07, 2003 8:48 PM
To: 'NYPHP Talk'
Subject: RE: [nycphp-talk] Re: IM App



We built a dedicated chat app for a client's website once.  We used
Jabber and a Java client for the front end.  It worked great.
Although they hardly ever had anyone in the chat rooms to really test
the system under load.   I know this is not a PHP solution but
I don't think PHP is well suited for a real-time application like IM.

| Larry Velez | http://sinu.com |

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
On Behalf Of Chris Shiflett
Sent: Thursday, August 07, 2003 2:26 PM
To: talk at lists.nyphp.org
Subject: [nycphp-talk] Fwd: Undelivered Mail Returned to Sender


--- crisscott at netzero.com wrote:
> That is helpful. I obviously wasn't looking at this from the right
> angle. But like David mentioned, I would think that having lots users 
> sleeping and polling would cause some strain on the server.

Well, it wouldn't cause much strain at all, since it's only having to
send a little chunk every time someone sends a message.

What it does do is tie up connections. Most people who do this consider
the Web server to be a chat server and dedicate it to that purpose (or,
at least dedicate some Web server to the purpose, perhaps listening on
an alternate port). Because the strain is very little, you can increase
your maximum number of child processes/threads/whatever a ton without
increasing your load too much (this tuning requires a bit of experience
with tuning Web servers, but trial an error is also very educational).
You just need to be able to support a connection for every user in a
chat.

Hope that helps.

Chris

=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/ _______________________________________________
talk mailing list
talk at lists.nyphp.org http://lists.nyphp.org/mailman/listinfo/talk

_______________________________________________
talk mailing list
talk at lists.nyphp.org http://lists.nyphp.org/mailman/listinfo/talk







More information about the talk mailing list