在没有 Node.js 的情况下独立使用 socket.io
(JavaScript 新手)
我正在尝试构建一个基于 JavaScript 的客户端应用程序,通过套接字与服务器应用程序进行通信。我遇到了 socket.io。是否可以在没有任何 Node.js 依赖的情况下使用 socket.io?
我克隆了socket.io github并编写了一个简单的客户端html来连接到服务器(如果需要,可以发布代码)。但它无法连接到服务器。
(背景信息:我们需要一个在 Win32 上运行的简单配置客户端实用程序,它与支持使用自定义数据包格式协议进行套接字通信的自定义服务器进行通信。我们不通过通常的 MFC/.NET,而是考虑 HTML/JS/ CSS 是一个更好的解决方案,为此,我考虑了以下选项:
- Titanium:可以工作,但需要安装运行时
- HTML5 WebSocket:未得到广泛支持 - 可在 Chrome 上工作,但需要 IE10
- socket.io:尝试使其工作
- 还有其他吗? (如有必要,可以将此问题作为单独的线程发布) )
(JavaScript newbie)
I am trying to build a JavaScript based client app that communicates with a server app over socket. I came across socket.io. Is it possible to use socket.io without any node.js dependencies?
I have cloned socket.io github and wrote a simple client html to connect to the server (Can post the code if required). But it does not connect to the server.
(Background info: We need a simple config client utility that runs on Win32 that communicates with a custom server that supports socket communication with a custom packet-format protocol. Instead of going through the usual MFC/.NET, we think HTML/JS/CSS makes a better solution. For this purpose, I have considered the following options:
- Titanium: Works, but requires runtime to be installed
- HTML5 WebSocket: Not widely supported - works on Chrome but requires IE10
- socket.io: Trying to get it to work
- Any other?
(Can post this question as separate thread, if necessary)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
建立成功的 Socket.IO,您的自定义服务器必须遵循规范,或使用其他服务器socket.io的实现
https://github.com/learnboost/socket.io/wiki 在其他语言中部分包括socket.io的一些服务器实现
Establish a successful Socket.IO, your custom server must follow the spec, or use other server implementation of socket.io
https://github.com/learnboost/socket.io/wiki the In other languages part include some servers implementation of socket.io
据我了解,你需要一个没有node.js的socket.io服务器,对吧?如果像使用跨浏览器 WebSockets 一样使用 socket.io 就足够了,下面来自 socket.io 网站的示例很好地说明了我的意思:
这将使您的服务器代码非常简单。当然,您可以找到一些适合您的语言的 WebSockets 库,甚至可以编写自己的库。查看这个SO问题作为示例。
或者,如果您想使用socket.io 协议,则有针对不同语言(例如 python 和 java)的 socket.io 库列表。
As I understand, you need a socket.io server without node.js, right? If to use socket.io just as cross-browser WebSockets would be sufficient, and what i mean by that is nicely illustrated in the following example from socket.io web site:
It would make your server code very simple. Surely, you can find some WebSockets library for your language or even write your own. Look at this SO question for examples.
Or if you want to use socket.io protocol there is list of socket.io libraries for different languages, like python and java.
原始问题的答案中有很多噪音。让我尝试尽可能清楚地回答这个问题。
简短的回答是肯定的。但是,您将具有 Flash 依赖性。您可以在 socket.io 的常见问题解答中了解如何执行此操作。
There's a lot of noise in the answers to the original question. Let me try to answer the question as clear as I can.
The short answer is yes. You will however have Flash dependency. You can read about how to do this in socket.io's faq.