Socket.IO 中的跨域连接 [英] Cross-domain connection in Socket.IO

查看:66
本文介绍了Socket.IO 中的跨域连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以跨域使用Socket.IO吗?如果是这样,怎么做?网上都提到了这种可能性,但没有在任何地方给出代码示例.

Is it possible to use Socket.IO in a cross domain manner? If so, how? The possibility is mentioned around the web but no code examples are given anywhere.

推荐答案

引用socket.io FAQ:

Socket.IO 是否支持跨域连接?

当然,在每个浏览器上!

Absolutely, on every browser!

至于它是如何做到的:Native WebSockets 在设计上是跨域的,socket.io 提供了一个用于跨域 flash 通信的 flash 策略文件,XHR2 可以使用 CORS,最后你可以始终使用 JSONP.

As to how it does it: Native WebSockets are cross-domain by design, socket.io serves a flash policy file for cross-domain flash communication, XHR2 can use CORS, and finally you can always use JSONP.

这篇关于Socket.IO 中的跨域连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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