简体   繁体   中英

how to implement a websocket server with node.js?

are there any examples? And how node.js communicates with traditional php scripts ?

Take a look at socket.io. This includes a client and a server-side library.

http://socket.io

Well, you should read the (now deprecated) Specification .

For a straight forward implementation you can take a look at my code here:
https://github.com/BonsaiDen/NodeGame-Shooter/blob/master/server/nodegame/ws.js

If you like to have a big wall of abstraction with a trillion fall backs, take a look at: http://socket.io/

BUT...

Keep in mind when building your own one, the WebSocket protocol is about to change due to recently discovered security vulnerabilities:
http://hacks.mozilla.org/2010/12/websockets-disabled-in-firefox-4/
http://blog.pusherapp.com/2010/12/9/it-s-not-websockets-it-s-your-broken-proxy

As for the PHP part, it's unclear to me what you exactly want to do you should give us more information about that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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