WebSocket概述

WebSocket概述

概述

WebSocket需要Browser和Server两方面的支持。

WebSocket是基于TCP的一个双向协议,也就是说可以从Client发消息到Server,也可以从Server发消息到Client。那Http不是也可以吗?其实Http是一个请求一个响应,响应结束后连接就关闭了,Server再想发消息到Client就没有办法了。其实也就是说无状态的。譬如消息推送就很难用这种无状态的Http来实现,你不知道什么时候有消息要发给Client,重要的是Server根本不知道如何联系Client。WebSocket也就是为了解决这么一个问题,Server能够定位到WebSocket,所以一直保持这个连接。从这里可以获得更加形象具体的了解http://angelozerr.wordpress.com/2011/07/23/websocketsjettystep1/

WebSocket的Client端实现比较简单,只要Browser支持就好办了,可以参考这篇文章:Writing WebSocket client applications

WebSocket的Server端实现则是各个平台不一样,譬如Java或者NodeJS,这些你都可以在后面的相关参考里面找到。其中一篇基于Tomcat的实现的中文博客似乎比较简单明了http://redstarofsleep.iteye.com/blog/1488639

其实除了了解具体如何运用WebSocket之外,还需要知道该在什么场景中运用。个人理解,如聊天室或者网络游戏中是可以用到的。这里的一个共同的特点是,需要Server主动将消息推送到Client端。

相关参考:

Writing WebSocket client applications Sample from Mozilla

Socket.IO Socket.IO aims to make realtime apps possible in every browser and mobile device, blurring the differences between the different transport mechanisms. It's care-free realtime 100% in JavaScript.

WAMP WAMP is an open WebSocket subprotocol that provides two asynchronous messaging patterns: RPC and PubSub

WebSocket Server in Jetty Detail introduction WebSocket implementation in Jetty

WebSocket Server in Tomcat Detail introduction WebSocket implementation in Tomat, including client html and server java code

负载平衡,MQTT协议支持,修正大量Bug,最新稳定版 Delphi7/XE6/XE7/XE8 ******************************************************* sgcWebSockets ******************************************************* [*] : Bug [+] : New [-] : Deleted [/] : Breaking changes Versions -------- 4.1.0: 2017 April [+] : Added support for Rad Studio 10.2 Tokyo. [+] : Added support for Linux compiler. [+] : MQTT client, added subscribe method. [+] : MQTT client, added unsubscribe method. [+] : MQTT client, added publish method. [+] : MQTT client, added Authentication property, allows to set user and password to authenticate against MQTT Server. [+] : MQTT client, added HeartBeat property, keeps alive connection. [+] : MQTT client, added LastWillTestament property, when client disconnects, sends a message to other connected clients. [+] : New Property "NotifyDeletes" in Dataset Server Protocol, if enabled (by default) broadcast deleted record to all clients. [+] : New Method "BroadcastRecord" in Dataset Server Protocol, sends dataset record values to all clients. [+] : New Method "MetaData" in Dataset Server Protocol, sends metadata info to a single client. [+] : New Method "Synchronize" in Dataset Server Protocol, sends dataset record values to a single client. [*] : Fixed Bug ReadTimeout and ConnectionTimeout in client component. [*] : Added Guid property to Client File Protocol. [*] : Fixed Bug Invalid Character when trying to access to built-in javascript libraries. [*] : Fixed Bug File Protocol when BufferSize was set to zero, file was not saved properly. [*] : Fixed Memory Leaks on NextGen compiler. [*] : Fixed WebRTC Chrome console errors.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值