哪些TCP协议可用于客户端到客户端的通信? [英] What TCP protocols are usable for client to client communication?

查看:143
本文介绍了哪些TCP协议可用于客户端到客户端的通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

许多时候,客户要求为其Web应用程序提供即时消息(IM)和其他客户端到客户端(P2P)通信等功能.通常,如何在普通的Web浏览器中完成此操作?例如,我看过 Google Wave (和Gmail)的演示,它们可以通过常规浏览器进行即时通讯.是通过HTTP吗?还是XmlHttpRequest(AJAX)提供了进行此类通信所需的后端?

Manytimes clients ask for features like instant messaging (IM) and other client-to-client (P2P) communication for their web apps. Typically how is this done in normal web browsers? For example I've seen demos of Google Wave (and Gmail) that are able to IM from a regular browser. Is this via HTTP? Or does XmlHttpRequest (AJAX) provide the necessary backend for such communication?

最重要的是,我想知道服务器如何唤醒"远程客户端,比如说发送IM?还是客户端必须为新的IM保持轮询"消息服务器?

More than anything I wonder how can a server "wake up" the remote client, lets say for sending an IM? Or does the client have to keep "polling" the message server for new IMs?

推荐答案

通常,浏览器会在服务器上轮询新消息.为了提高效率,经常采用的一种方法是'

Typically the browser will poll the server for new messages. One approach that is often done to make this more efficient is the 'long poll' (see also this link) - the server responds immediately if it has anything; otherwise, it waits, keeping the connection open for a while. If a message comes in, it immediately wakes up and sends it, otherwise it comes back with a 'nope, check back' after a few tens of seconds. The client them immediately redials to go back into the long-polling state.

这篇关于哪些TCP协议可用于客户端到客户端的通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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