简体   繁体   中英

When to use socket.io?

I am learning NodeJS and was able to make a server and an iPhone app that issues an HTTP GET request to the server and retrieve a JSON string from it. I didn't need to use socket.io for this. So why would I need to use it?

If you are just pulling JSON from the server your solution works fine. However suppose you want to push data from the server back to the client. Socket.io is a very elegant solution for doing this. Firstly because it handles the push side and secondly because it handles browser degradation gracefully as the 'jQuery of sockets'

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