博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
why websocket over ajax
阅读量:6803 次
发布时间:2019-06-26

本文共 1178 字,大约阅读时间需要 3 分钟。

hot3.png

To handle chat-related messaging, you could poll the server with Ajax. But to make
this application as responsive as possible, you’ll avoid using traditional Ajax as a means
to send messages. Ajax uses HTTP as a transport mechanism, and HTTP wasn’t
designed for real-time communication. When a message is sent using HTTP, a new
TCP/IP connection must be used. Opening and closing connections takes time, and
the size of the data transfer is larger because HTTP headers are sent on every request.
Instead of employing a solution reliant on HTTP, this application will prefer Web-
Socket (http://en.wikipedia.org/wiki/WebSocket), which was designed as a bidirec-
tional lightweight communications protocol to support real-time communication.
Since only HTML5-compliant browsers, for the most part, support WebSocket, the
application will leverage the popular Socket.IO library (http://socket.io/), which
provides a number of fallbacks, including the use of Flash, should using WebSocket
not be possible. Socket.IO handles fallback functionality transparently, requiring no
additional code or configuration. 

From: Node.js in action

转载于:https://my.oschina.net/uniquejava/blog/332811

你可能感兴趣的文章
HTTP基础
查看>>
JavaSE学习笔记(五)——类与对象
查看>>
Android之高仿飞鸽传输热点创建与搜索模块
查看>>
Struts2、Spring和Hibernate应用实例(中)
查看>>
[转]MYSQL性能优化分享(分库分表)
查看>>
用php实现异步执行任务的队列(一)
查看>>
AngularJS表单验证操作例子分享
查看>>
RabbitMQ 的安装与工作模式
查看>>
视图的跳转,ViewController的使用 。试图出现启动消失过程
查看>>
博科300光纤交换机配置手册/操作方法/密码设置/用户指南大全
查看>>
HTML Dom
查看>>
Linux下为PHP添加扩展库的方法
查看>>
HBase(四):HBase API判断表是否存在,结果问题爆棚。。
查看>>
宏定义冲突
查看>>
cobbler-自动化部署
查看>>
我的友情链接
查看>>
tracepath
查看>>
java多线程基础复习
查看>>
我的友情链接
查看>>
iOS:使用minimumScaleFactor控制字体大小自适应
查看>>