A protocol for bidirectional real-time data transfer between the client and server. Uses TCP under the hood.
It is suitable for long-running applications, or those that need to get real-time data. Example applications include:
- real-time web apps
- stock trading websites
- chat apps
- gaming
Web sockets are more efficient than using the HTTP protocol because:
- the client does not have create new connections
- the server doesn’t have to respond with empty response1
References
https://www.youtube.com/watch?v=pnj3Jbho5Ck
Footnotes
-
If HTTP long polling is used, then this overhead goes away as the server only response once it has the data for the client. ↩