WebSocket
来源:互联网 发布:去视频马赛克软件 编辑:程序博客网 时间:2024/06/05 01:58
What is the WebSocket API?
The WebSocket API is the next generation method of asynchronous communication from client to server. Communication takes place over single TCP socket using the(unsecure) or
(secure) protocol and can be used by any client or server application. WebSocket is currently being standardized by the W3C. WebSocket is currently implemented in Firefox 4, Chrome 4, Opera 10.70, and Safari 5.
What's great about the WebSocket API that server and client can push messages to each other at any given time. WebSocket is not limited in its nature the way that AJAX (or XHR) is; AJAX technologies require a request to be made by the client, whereas WebSocket servers and clients can push each other messages. XHR is also limited by domain; the WebSocket API allows cross-domain messaging with no fuss.
AJAX technology was a clever usage of a feature not designed to be used the way it is today. WebSocket was created for the specific purpose of bi-direction message pushing.
WebSocket API Usage
Focusing on the client side API only (because each server side language will have its own API), the following snippet opens a connection, creates event listeners for connect, disconnect, and message events, sends a message back to the server, and closes the connection.
// Create a socket instancevar socket = new WebSocket('ws://localhost:…………………………………………………………………………详细页面:http://www.verydemo.com/demo_c134_i11390.html
- WebSocket
- WebSocket
- WebSocket
- websocket
- WebSocket
- WebSocket
- WebSocket
- WebSocket
- websocket
- websocket
- WebSocket
- WebSocket
- WebSocket
- WebSocket
- websocket
- websocket
- websocket
- websocket
- CSS技巧荟萃:了解CSS页面布局和加载流程
- 视频监控知识
- 用Python处理Cookie - Python开发技术文章
- C#窗体应用程序之 单选按钮与分组框 源代码
- POJ 3616-Milking Time (基础DP)
- WebSocket
- 27 岁后月薪低于 8K,会被淘汰吗?
- POJ - 1860 URAL - 1162 Currency Exchange
- Android Soundpool学习
- Block的用法
- C/C++语言指针使用总结
- node-schedule的使用
- FancyUpload3 文件上传
- 初学java,写的一个小程序遇到点问题,又碰上论坛关闭,在此上代码,希望能有人帮我看下,多谢