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:

  1. the client does not have create new connections
  2. the server doesn’t have to respond with empty response1

References

https://www.youtube.com/watch?v=pnj3Jbho5Ck

Footnotes

  1. If HTTP long polling is used, then this overhead goes away as the server only response once it has the data for the client.