Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
websocket 簡介
Search
ChiaChiaTsao
September 30, 2016
Technology
61
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
websocket 簡介
20160923 前端例會分享
ChiaChiaTsao
September 30, 2016
Other Decks in Technology
See All in Technology
IBC 2026 動画技術関連レポート / IBC 2026 Report
cyberagentdevelopers
PRO
2
450
Claude Codeで作ったアプリを安全に公開する/Built with Claude Japan 2026
yoshidashingo
0
220
【dbts2026】AIエージェントの 判断と探索を変える、 データベース エンジニアリング― 既存DBの処理と依存関係から作る、オペレーショナルオントロジー ―
shisyu_gaku
0
260
MCPでAIが自分で調べに行く
cdataj
0
110
[dbts2026]数十PBの超巨大データ×AI活用を支えるSnowflakeの実力〜大規模環境におけるアーキテクチャと運用のリアル〜
y_matsubara
0
120
慶應義塾大学 AI実践05 論文執筆の仕組み化
keio_smilab
PRO
7
3.8k
AWS構成から考えるWebセキュリティ ― WordPressの構築経験から考える公開範囲と更新運用【JAWS FESTA 2026 in AKITA】
cscengineer
PRO
2
380
Reticulum, le réseau cypherpunk dont vous avez besoin !
rlifchitz
0
110
レガシーコードに対する loop engineering的なAI開発プロセス導入について
kubell_hr
0
290
Agent Harnessはどう作る?事例から学ぶAI Agentの設計思想
sergicalsix
0
220
An Introduction to Context Ontology Accelerator (teaching AI agents what your data means)
inariku
PRO
1
180
eBPF 簡介 2026 版
shunghsiyu
0
190
Featured
See All Featured
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
560
Fireside Chat
paigeccino
43
4.1k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
121
130k
Navigating Team Friction
lara
192
16k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Paper Plane
katiecoart
PRO
5
55k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.5k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
Optimizing for Happiness
mojombo
378
71k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Transcript
Websocket 簡介 20160923 報告人:曹家嘉
Client - Server 如何溝通? HTTP Requset / Response 須由 Client
發起 Requset -> Server 接收後回傳 Response 通常 Server 都是處於被動等待 Client 來要求資料
New feature • Client - Server 雙向溝通 • 快速反應時間越短越好 •
頻繁使用短訊息相互溝通 發展出 Comet 機制 ex: Long polling, Streaming 讓 Client 每隔一段時間對 Server 發出 HTTP Request 來確認 Server 是否有資料回傳
Comet 的問題 • Server 與 Client 之間建立 2 條連線,對Server的負擔極大。 •
Client 需不斷發出 Request 給 Server 確認是否有資料回傳,而 HTTP Request Header 占了大量的 Bytes。 • Client 也需要維持與 Server 的連線資訊來判斷 Server 回傳的資 料並進行動作。
Websocket 的出現 IETF 制定的協定(RFC-6455),W3C 在 HTML5 規範內制定了 WebSocket API的標 準。建立於
HTTP 原有的架構之上,和 HTTP 一樣使用 80 與 443 port。 改善 Comet 的缺點 • 將連線數量減少為一條,全雙工連線。 • 當 Server 有資料更新時,自動傳送給 Client 進行即時更新。 • Header 只有 2 bytes 長度大小。
建立 Websocket 連線 1. Client 發送 HTTP Request 給 Server,並要求
Server 將 HTTP Protocol 更新為 WebSocket Protocol。 2. 待 Server 更新完後即完成了 HandShake,此時 Server 與 Client 就 建立了一條雙向的 WebSocket 連線。 3. 雙方能開始做即時的資料傳輸。
Client API Event & Lifecycle onOpen onClose onError onMessage 連線錯誤
強制中斷 接收資料 關閉連線 資料 錯誤
Websocket 使用例 • 多人協作: Hackpad, trello • 線上多人網頁遊戲: Agar.io •
聊天室: http://socket.io/demos/chat/
Reference • WebSocket – 新一代網路傳輸技術 • When to use a
HTTP call instead of a WebSocket (or HTTP 2.0) • Socket.IO