如何建立浏览器到浏览器(点对点)连接? [英] How can I make a browser to browser (peer to peer) connection?

查看:219
本文介绍了如何建立浏览器到浏览器(点对点)连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在客户端使用 HTML5 CSS JavaScript 编写网站,以允许直接连接tcp / ip连接之间的客户端浏览器之间加载页面



我需要这样做以减少延迟,因为该网站将要求从其中一个输入用户会尽快传输给其他用户,因此从客户端A发送数据到服务器,然后发送到客户端B不是一个好的选择。



我读过以前的帖子在这个问题上,但没有可以找到的工作解决方案/例子。从我读到的,客户端之间的直接连接可以使用像Silverlight,Java或Flash这样的插件。



是否有解决方案不需要插件?我只想使用JavaScript。

解决方案

这里的Stackoverflow是关于浏览器中P2P连接的几个主题:


  1. com / questions / 4807685 / what-techniques-are-available-to-do-p2p-in-the-browser>在浏览器中可以使用什么技术来做P2P?
  2. HTML5是否支持点对点(而不仅仅是WebSockets)

  3. HTML5 Websockets可以直接连接2个客户端(浏览器)而无需使用服务器(P2P)
  4. 是否有可能在Web浏览器中创建点对点连接?


  5. HTML 5 Peer to Peer Video Possibilities?
  6. https://stackoverflow.com/questions/6993042/is-webrtc-implemented-in-any-browsers-yet\">是否在任何浏览器中都实现了WebRTC?

正如大多数主题中所提到的,2008年HTML5工作草案都有一个点对点连接部分:





由于 2009年2月12日的W3C工作草案对等连接部分消失了。但是这个P2P连接并没有消失。它在WebRTC(实时通信)规范中名称为PeerConnection:



自10月31日2011年,W3C编辑草案是一份正式的工作草案:



爱立信实验室(2011年5月)在修改的WebKit中存在PeerConnection(基于UDP)的唯一实现,该工具运行良好。一些补丁现在在WebKit中(2011年10月 - 见下面的更新!):



另外,WebRTC计划是Google的一个项目,Mozilla和Opera。因此,他们正在继续PeerConnection的规范:



可能Chrome(使用WebKit)将是第一个支持WebRTC和PeerConnection的主流浏览器: b
$ b



自2012年1月18日起,< Chrome还支持WebRTC 。Chrome浏览器支持WebRTC。它可以在开发者频道(Windows,OSX,Linux)和Canary构建中使用( Windows和OSX)通过 chrome:// flags 。它只支持 MediaStream ,如视频和音频,可以用几个演示。到目前为止,不支持传输 String / ArrayBuffer / ...等应用程序数据。



由于 2012年3月16日,WebRTC编辑草稿分开 String , ArrayBuffer Peer-to-peer Data API >和 Blob )。 Chromium希望很快实施Data API (2012年4月10日) )。

4月3日,Mozilla发布了第一个有关

DataChannel计划用于Chrome的25版本,在旗帜后面,同时它可以在Firefox Nightly / Aurora(2012年12月12日)进行测试:



2018年:DataChannel仍然是实验性的,但在当前版本的Chrome和Firefox中可用:




How can I write a website using HTML5, CSS and JavaScript on client side that will allow direct tcp/ip connection between the client browsers once the page is loaded.

I need to do this to to reduce latency since the site will require that the input from one of the users to be transmitted to the other user as soon as possible so sending data from client A to Server and then to client B is not a good option.

I read previous posts on this subject but there were no working solution/examples available that I could find. From what i read the direct connection between clients can be made using plugins like Silverlight, Java or Flash.

Is there any solution that would not require plugins? I would like to use only JavaScript.

解决方案

Here on Stackoverflow are several topics about P2P connections in browsers:

  1. Will HTML5 allow web apps to make peer-to-peer HTTP connections?
  2. What techniques are available to do P2P in the browser?
  3. Does HTML5 Support Peer-to-Peer (and not just WebSockets)
  4. Can HTML5 Websockets connect 2 clients (browsers) directly without using a server (P2P)
  5. Is it possible to create peer-to-peer connections in a web browser?
  6. Do websockets allow for p2p (browser to browser) communication?
  7. HTML 5 Peer to Peer Video Possibilities?
  8. Is WebRTC implemented in any browsers yet?

As mentioned in most of the topicts, both 2008 HTML5 working drafts were having a section "Peer-to-peer connections":

Since the W3C Working Draft 12 February 2009 the section "Peer-to-peer connections" disappeared. But this P2P connection is not gone. It's back under the name PeerConnection within the WebRTC (Real-Time Communications) specifications:

Since 31 October 2011, the W3C Editor's Draft is an official Working draft:

The only implementation of the PeerConnection (UDP based) exists in the modified WebKit by the Ericsson labs (May 2011), which is working quite well. Some patches are in WebKit now (Oct. 2011 -- see updates below!):

Additionally, the WebRTC initiative is a project by Google, Mozilla and Opera. Thus, they are continuing the specification on PeerConnection:

Probably Chrome (uses WebKit) will be the first major browser supporting WebRTC with PeerConnection:

Since 18th January 2012, Chrome is supporting WebRTC as well. It can be uses in the Dev channel (Windows, OSX, Linux) and the Canary build (Windows and OSX) by enabling it under chrome://flags. It only only supports MediaStream like Video and audio and can be tested with several Demos. Transferring application data like String/ArrayBuffer/... is not supported until now.

Since 16th March 2012, the WebRTC Editor's Draft separates a "Peer-to-peer Data API" to send and receive generic application data (String, ArrayBuffer and Blob). Chromium wants to implement the Data API soon (10th April 2012).

On April, 3rd, Mozilla published a first working example on WebRTC for Firefox as well.

DataChannel is planned for version 25 of Chrome, behind a flag, meanwhile it can be tested in Firefox Nightly/Aurora (12th December 2012):

2018: DataChannels are still experimental, but available in current versions of Chrome and Firefox:

这篇关于如何建立浏览器到浏览器(点对点)连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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