什麼是WebSocket? —初學者編碼



什麼是WebSocket? —初學者編碼

http://colorcode.io/course/tech-in-90-seconds/?video=websockets

90秒內的技術-WebSockets

作者:約翰·保羅(John K. Paul)

WebSockets是另一種協議,類似於http,但是在瀏覽器內部卻更多。您可能從未在瀏覽器的位置欄中看到過以WS開頭的URL,但是在幕後,您喜歡的許多應用程序(例如Slack,Gmail和Twitter)都在使用Web套接字。

瀏覽器內部的典型HTTP請求響應周期類似於1.有人單擊鏈接或在2.中鍵入url。向伺服器發出http請求。3.伺服器用一些數據響應瀏覽器。這需要一些東西,使某種系統能夠很好地適用於各種各樣的事情,例如閱讀新聞或檢查天氣,但是如果您想在這個世界上獲得更多實時信息,例如聊天,電子郵件或推特,我們必須打電話說「嘿,還有其他什麼」,「嘿,還有其他什麼?」所有的時間。

WebSockets的目的是允許與後端伺服器的持久連接。就像電話一樣,雙方都無需掛斷電話,如果在幾秒鐘或幾分鐘後收到新信息,則無需打新電話。如果伺服器具有用於瀏覽器的數據,則僅發送該數據,而不必等待瀏覽器詢問「其他任何內容」的時間。

使用該技術的開發人員可以創建一個後端和前端組合系統,該系統可以非常快速地對新數據做出響應,就像新數據流入瀏覽器一樣,因此WebSockets是「實時」 Web應用程序的基礎。 。

29 comments
  1. You explain so complicated concepts so clearly! You should really consider making udemy courses or something. I would definitely buy them

  2. Wow man, in a world of super long drawn out videos – yours was perfect. You went straight to the point, no extraneous info – succinct and to the point. You just got a subscriber

  3. Help Please!!.. I recently learned node.js and now learning web sockets, to use socket.io (or anywebsocket)
    do we have to write a special server ?, so WebSocket can bind on to it?
    or we can just bind to the main hosting server (mine at hostgator), Because I m making this chatting website and planning to upload to a hosting site, where they traditionally provide you with server you just have to put you file on that server, so is it like I have to make server inside server or I get my WebSocket latch to that traditional server? I m so confused,
    am I missing something? I googled but can't seem to find anything, any
    help from you guys will be great, Please Explain! lastly sorry for my
    bad english.

Comments are closed.