ds3464 2010-06-04 11:23
浏览 101

PHP与ajax轮询实时聊天

I need to create a chat similar to facebook chat.

I am thinking to use ajax polling ( to send request every 2-3 seconds ).

Is this a good approach ? Or I need to use other server side languages like erlang and server-comet ?

  • 写回答

2条回答 默认 最新

  • douping1581 2010-06-04 11:50
    关注

    Or I need to use other server side languages

    No - that's not really relevant - the biggest problem is that HTTP does not support push notifications - so the language you use on the web server is pretty much irrelevant.

    server-comet ?

    Comet is programming technique - not a language - specifically designed to address the absence of push in HTTP. Conventionally, a browser sends a request, the webserver creates a response then sends it back to the client. With Comet, the webserver waits until either:

    1) there is some update to include in the response

    2) a timer expires

    Before sending the response. A consequence of this is that it results in a high number if inactive connections to the webserver - which can cause performance issues.

    An alternative approach is to use HTTP to delver a client program to run in the browser which the connects to the chat server using a different protocol. Its possible to do this with ActiveX, Java or flash - all of which have major drawbacks - not least portability.

    There are several pre-written solutions out there using PHP and javascript - hint - if the docs don't mention Naggle then they've probably not thought about scalability/performance.

    C.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?