Join Joseph LeBlanc for an in-depth discussion in this video What are WebSockets?, part of Node.js First Look.
Have you ever seen Facebook's chat feature and wondered how I can make something similar for my web site? Fortunately, WebSockets make it easier to add chat rooms, notification systems, and other real-time features than ever before. Node has tools ready to go to help you make the most of WebSockets quickly. So why are we using WebSockets? Traditionally, HTTP has been a stateless protocol. That means a web browser will connect to a web server, get the content, and then close the connection. This made it very difficult to do live features on a web site.
So now we have WebSockets. WebSockets are a bi-directional communication protocol between the server and browser. WebSockets use TCP instead HTTP. So that way you get around the statelessness of HTTP. WebSockets are native to the browsers that support it. There're no hacks, no iFrames, and no Flash used to implement WebSockets. However, the disadvantage with WebSockets is that it support for them is inconsistent. Not all web browsers support WebSockets and the ones that do don't support them in consistent ways.
Socket.io will automatically detect and use the best protocol. This chapter will use Node and Socket.io to create a chat room. Socket.io will take care of the connection between the browser and node which will allow us to focus on the chat functionality.
- Using the Socket.IO Node package to achieve "live" effects like Facebook notifications
- Scraping web sites using jQuery without a browser
Skill Level Beginner
Q: Does the instruction from "Selecting through browserless jQuery" work for Windows users?
A: The “Selecting through browserless jQuery” video does not work on Windows