简体   繁体   English

设置网络套接字

[英]setting up web sockets

When using web sockets all the tutorials I can find talk about the code for the client side. 使用Web套接字时,所有教程都可以找到有关客户端代码的信息。 But the server side is just left out. 但是服务器端只是被忽略了。 What does the connection url here actually point too? 这里的连接网址实际上也指向什么? Do I need to also be using PHP, Ruby, node.js or any server side language? 我是否还需要使用PHP,Ruby,node.js或任何服务器端语言?

var connection = new WebSocket('ws://html5rocks.websocket.org/echo', ['soap', 'xmpp']);

Tutorial referenced: 引用的教程:

http://www.html5rocks.com/en/tutorials/websockets/basics/ http://www.html5rocks.com/zh-CN/tutorials/websockets/basics/

There are some server side languages that have Websockets support, I personally recommend using: 有一些支持Websockets的服务器端语言,我个人建议使用:

Socket.io 套接字

Who works over node.js, it's very easy to setup and a good starting point. 谁负责node.js,它的设置非常容易,并且是一个很好的起点。 Later you can have an Websockets endpoint in any language. 以后,您可以使用任何语言的Websockets端点。 Java and C# solutions are a bit complicated by the time. Java和C#解决方案在时间上有些复杂。

Yes, you need a server that handles websockets. 是的,您需要一个处理websocket的服务器。 Many do including Apache HTTPD, Apache Tomcat, Play framework, and nodejs. 许多都包括Apache HTTPD,Apache Tomcat,Play框架和nodejs。

Here is an example: http://www.tomcatexpert.com/blog/2012/05/01/how-apache-tomcat-implemented-websocket 这是一个示例: http : //www.tomcatexpert.com/blog/2012/05/01/how-apache-tomcat-implemented-websocket

Have you seen the great (and simple) echo sample on websocket.org ? 您是否在websocket.org上看到了出色(简单)的echo示例?

Also, Kaazing has a hosted WebSocket server, and a browser-based tutorial that walks you through a simple pub-sub example. 此外,Kaazing拥有一个托管的WebSocket服务器,以及一个基于浏览器的教程,为您介绍了一个简单的pub-sub示例。 Check out: 查看:

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM