与客户端的持久连接 [英] Persistent connection with client

查看:103
本文介绍了与客户端的持久连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一个通用的方法来实现一部分应用程序的JavaScript和提供持久连接到服务器?我需要服务器能够将数据推送到客户端,而不管客户端是否在防火墙之后。提前感谢

Is there a general way to implement part of an application with JavaScript and supplying a persistent connection to a server? I need the server to be able to push data to the client, regardless of the client being behind a firewall. Thanks in advance

推荐答案

请参阅彗星 - 它像ajax,但它保持连接打开,所以服务器可以推送信息到客户端。

See Comet - it's like ajax, but it holds a connection open so the server can push information to the client.

请注意,符合规范的浏览器只能保留2个连接(注意:大多数新型浏览器不再符合)到特定域(默认情况下),因此您可能希望拆分您的域(例如www.yourdomain.com和comet.yourdomain.com),以便您不会极大地减慢您的网页的加载速度。或者你可以确保你不打开彗星连接,直到加载其他所有东西。这只是一些要小心的事。

Note that compliant browsers will only hold 2 connections (note: most modern browsers no longer comply) to a particular domain (by default), so you might want to split your domains (e.g. www.yourdomain.com and comet.yourdomain.com) so that you don't drastically slow down the loading of your pages. Or you could just make sure you don't open the comet connection until everything else is loaded. It's just something to be careful of.

这篇关于与客户端的持久连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆