FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » chat on web, Ajax ?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: chat on web, Ajax ? [message #177161 is a reply to message #177157] Fri, 24 February 2012 14:28 Go to previous messageGo to previous message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma:
Senior Member
On 2/24/2012 2:59 PM, sl@exabyte wrote:
> Hi folks.

Hi again,


>
> I thought I have gathered all pieces I need, then suddenly I realise there
> is still one problem.

Some of us guessed by reading your former thread. :-)


>
> I am implementing chat on the web, ie on a browse. On browser, I can only
> use javascript. So the problem is what method to use to listen for incoming
> data.

Yes.
That is the problem: typical http requests data from some server, and
after it arrives, that's it.
A normal http request:
1) Browser sends request to server.
2) server answers
the end.
How to let the browser listen to the server?

Short answer: You cannot. Not without some tricks or additional software
(Java, Flash for example).

Read up here first:
http://en.wikipedia.org/wiki/Push_technology#HTTP_server_push

You can see on that page that a few experiments have been tried, but
none of them if fully reliable.
For example: multipart/x-mixed-replace is not supported by IE, and I
don't know about mobile devices.

You have 2 options:
1) Make a client-pull approach, eg with XHR ("Ajax").
http://en.wikipedia.org/wiki/XMLHttpRequest
Advantage: Easy to implement.
Drawback: All the connected clients will be sending update-requests all
the time. This will lead to extra serverload which can kill the server
if you have many clients trying to chat.

2) Use additional software that CAN listen.
Problem: See former thread: Suppose your server wants to PUSH new data
to some client: How to deliver that behind a firewall/NAT? To which port?

Maybe IP6 and UPNP can help you out? I am not sure to be honest.
http://en.wikipedia.org/wiki/UPNP
UPNP can help you out of the NAT mess, but it isn't supported everywhere
(I disabled it because I don't want programs to open ports on my router.)

I once created a chat application, and resorted to PULL technology
because of all the problems. In my situation that was OK because the
load was low, and the approach worked (This was before the XHR days, and
I used a hidden frame and Javascript to pull the trick.)

Bottomline: Decide if you want to go CLIENT-PULL (easy, but limited) or
SERVER-PUSH (Hard).

But you better go to a networking group instead of this one.
These advanced networking protocols (both IP6 and UPNP) are quite
complex, and this isn't PHP related.

Regards,
Erwin Moller

>
> Ajax ? I am just wondering; Ajax does not seem to bother about port, I mean
> the standard method is "open socket at server, port 8888...".
>
> Of course, when data is sent to a php file on server, it must be port 80.
>
> Is this the only way on a browser ?
>
> Thanks.
>
>




--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: FastCGI & PHP
Next Topic: PHP socket and NAT
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 01:35:58 GMT 2024

Total time taken to generate the page: 0.03888 seconds