Html HTML5 Websockets 可以在不使用服务器的情况下直接连接 2 个客户端(浏览器)吗?(P2P)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4277351/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can HTML5 Websockets connect 2 clients (browsers) directly without using a server? (P2P)
提问by Justin
Using HTML5 Websockets, can I open a socket directly between 2 clients (browsers) (assuming I know their IP addresses and there are no NAT traversal issues). I want to send some data directly from one browser to another browser, essentially creating a P2P network. Everything I've read so far on the web, websockets are all used to communicate between client and server, but nothing about client to client.
使用 HTML5 Websockets,我可以直接在 2 个客户端(浏览器)之间打开一个套接字(假设我知道他们的 IP 地址并且没有 NAT 遍历问题)。我想将一些数据直接从一个浏览器发送到另一个浏览器,本质上是创建一个 P2P 网络。到目前为止我在网上读到的所有内容,websockets 都用于在客户端和服务器之间进行通信,但与客户端到客户端无关。
Thanks
谢谢
回答by kanaka
No
不
Already answered here for more details: Do websockets allow for p2p (browser to browser) communication?
已在此处回答更多详细信息:Do websockets allow for p2p (browser to browser) communication?
Update:
更新:
The WebRTCprotocol and API is making rapid progress and allows a Data Channel to be established between two peers (you still may need a STUN/TURN server for the initial NAT traversal and setup).
所述的WebRTC协议和API正在迅速进展,并允许两个对等体(可能仍然需要用于初始NAT遍历和设置一个STUN / TURN服务器)之间建立数据信道。
回答by kanaka
From past to future: Pick your implementation.
从过去到未来:选择您的实现。
- Most modern browsers support peer to proxy to peer using Websockets.
- Peer to peer is only available using certain browsers plug-ins for example Opera Uniteand FireFox Pow.
- Major browsers are in the process of implementing WebRTCwhich will allow peer to peer.
- 大多数现代浏览器都支持使用Websockets对等代理。
- 点对点只能使用某些浏览器插件,例如Opera Unite和FireFox Pow。
- 主要浏览器正在实施WebRTC,这将允许点对点。
回答by Jonas
If you just don't want to implement server your self you can use https://httprelay.io. No additional libraries required, all communication based on simple AJAX calls.
如果您只是不想自己实现服务器,则可以使用https://httprelay.io。不需要额外的库,所有通信都基于简单的 AJAX 调用。