less than 1 minute read


What are websockets?

  • Communication between a client (browser) and server
  • Bidirectional (data flows both ways)
  • Allows real-time data flow

  • wiki:
    • WebSocket is a computer communications protocol, providing full-duplex communication channels over a single TCP connection. The WebSocket protocol was standardized by the IETF as RFC 6455 in 2011, and the WebSocket API in Web IDL is being standardized by the W3C.

    • 中文: WebSocket是一種網路傳輸協定,可在單個TCP連接上進行全雙工通訊,位於OSI模型的應用層。WebSocket協定在2011年由IETF標準化為RFC 6455,後由RFC 7936補充規範。Web IDL中的WebSocket API由W3C標準化。WebSocket使得客戶端和伺服器之間的資料交換變得更加簡單,允許伺服器端主動向客戶端推播資料。在WebSocket API中,瀏覽器和伺服器只需要完成一次交握,兩者之間就可以建立永續性的連接,並進行雙向資料傳輸。


uses of websockets

  • multiplayer browser games
  • collaborative code editing
  • live text for sports/news websites
  • online drawing canvas
  • real-time to-do apps with multiple users


npm install

  • npm install express socket.io –save
  • npm install nodemon –save-dev


  • WebSockets (using Socket.io) Tutorial #1 - What Are WebSockets?

  • WebSockets (using Socket.io) Tutorial #2 - Creating an Express App

  • WebSockets (using Socket.io) Tutorial #3 - Using Socket.io

  • WebSockets (using Socket.io) Tutorial #4 - Emitting Messages

  • WebSockets (using Socket.io) Tutorial #5 - Broadcasting Messages


  • John Doerr on OKRs and Goal Setting at Google and Intel

  • Why the secret to success is setting the right goals John Doerr