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 #177162 is a reply to message #177161] Fri, 24 February 2012 14:51 Go to previous messageGo to previous message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma:
Senior Member
In article <4f479e77$0$6860$e4fe514c(at)news2(dot)news(dot)xs4all(dot)nl>,
Erwin Moller <erwinmollerusenet(at)xs4all(dot)nl> wrote:

> On 2/24/2012 2:59 PM, sl@exabyte wrote:

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

Or you can wait until websockets is more widely available - see RFC 6455:

<http://tools.ietf.org/html/rfc6455>

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
[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: Sun Nov 24 11:14:13 GMT 2024

Total time taken to generate the page: 0.04306 seconds