什么是打开一个TCP流服务器的最佳方法? [英] What's the Best Way to Open a TCP Stream to Server?

查看:104
本文介绍了什么是打开一个TCP流服务器的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

而是一个难以明确的问题,但基本上我想知道什么是最好的方式(而不是什么是你的意见,但这将最充分地满足要求我应当载明)是打开从流连接?客户端网页到服务器,这样既可以将数据发送到其他没有投票,我想这个词因为这是HTTP绑定与HTTP轮询这里的环境是一个聊天应用程序 - 我想一个流连接因此,浏览器是不是不断推高的要求的。客户端在这里是KnockoutJS和jQuery。我希望能够有数据推来回是JSON(或至少是可操纵的jQuery和淘汰赛的的toJSON )的服务器端 - 不太清楚它会是,但我很可能会在Linux服务器上运行,因此任何与兼容的正常工作。 如果有更多的细节,我可以提供,只是让我知道 - 我敢肯定我留下了一些明显的细节了。此外,我知道有可能是在这一个重复的问题,所以如果你的答案是不如关闭了欺骗和建立一个链接,这是伟大的。 谢谢!

Rather a hard to nail down question, but basically I'm wondering what the best way (and not "what's your opinion" but "which will most adequately meet the requirement i shall set forth) is to open a stream connection from a client side webpage to a server such that either can send data to the other without polling? I'm thinking the term for this is HTTP binding vs. HTTP Polling. The context here is a chat application - i'd like a streamed connection so that the browser isn't constantly pushing requests out. The client end here is KnockoutJS and jQuery. I'd like to be able to have the data pushed back and forth be JSON (or at least manipulatable by jQuery and Knockout's toJSON). The server end - not quite sure what it is going to be, but i'll probably be running on a linux server, so anything compatible with that works fine. If there's any more details i can provide, just let me know - i'm sure i left some obvious detail out. Also, i'm aware there's probably a duplicate question on this, so if your answer is as good as closing for a dupe and putting in a link, that's great. Thanks!

推荐答案

我想,你要寻找的被称为彗星。其基本思想是保持HTTP请求开放的时间较长,以便服务器可以发送数据到客户端,因为它涉及在,而不是必须不断地轮询服务器为新的数据的客户端。有实现它多种方式。这维基百科的文章是一个良好的开端更多信息。

I think what you're looking for is referred to as Comet. The basic idea is to keep HTTP requests open for longer periods of time so that the server can send data to the client as it comes in, rather than the client having to continually poll the server for new data. There are multiple ways to implement it. This Wikipedia article is a good start for more info.

MIX 2011的视频讨论了长轮询技术(虽然在建议视频是网络套接字将与未来的浏览器更好的解决方案)。

This MIX 2011 video discusses the long polling technique (although the suggestion in the video is that web sockets will be a better solution with future browsers).

这篇关于什么是打开一个TCP流服务器的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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