ããã§ã¯ HTML5 ã§å°å ¥ããã WebSocket ã«ã¤ãã¦èª¬æãã¾ãã ãããã WebSocket ã¯ãªãå°å ¥ãããã®ã§ããããï¼ ããã¯ä»»æã®ã¿ã¤ãã³ã°ã§ãµã¼ãã¼ããã¯ã©ã¤ã¢ã³ãã«å¯¾ãã¦ããã¼ã¿ãéã (ããã·ã¥ãã) æ段ãæä¾ããããã§ãã å¾æ¥ã® Web ã§ã¯ HTTP ãããã³ã«ã使ç¨ãã¦ãã¾ããHTTP ãããã³ã«ã¯ GET ã POST ãªã©ã®ãªã¯ã¨ã¹ããã¯ã©ã¤ã¢ã³ããããµã¼ãã¼ã«éãã ãµã¼ãã¼ã¯ããã«å¿çãã¦ã¯ã©ã¤ã¢ã³ãã«ãã¼ã¿ãéä¿¡ãã¾ãã ãµã¼ãã¼ãããã¼ã¿ãåå¾ããããã«ãã¯ã©ã¤ã¢ã³ããããªã¯ã¨ã¹ããæããå¿ è¦ãããã¾ãã ãã®ãããã¦ã§ãä¸ã§ãã£ããã¢ããªã±ã¼ã·ã§ã³çãå®è£ ããå ´åã¯ä¸ä¾¿ã§ãããªããªãããã£ããã¢ããªã§ã¯é常ã ãããã£ããåå è ã®çºè¨ã¯ããããçºè¨ãããã¿ã¤ãã³ã°ã§ä»ã®ãã£ããåå è ã«å¯¾ãã¦è¡¨ç¤ºãããã¯ãã§ããã ãã人ããã¤çºè¨ãããã
ãªãã«websocket ãµã¨ããµã¼ãã¼å´ããã¯ã©ã¤ã¢ã³ãã¸ã©ã¼ã«ããã¼ã¿éä¿¡ã£ã¦ã§ããªããï¼ï¼ ã¨æããã¨ããããããªãããªå 容ãã°ã°ã£ã¦ã¿ãã¨ããã ãã¼ãªã³ã°ã¨ãããã¨ã°ã«åºä¼ãã¾ããã ãããä»åã®å§ã¾ãã§ãã ç¥ãã¾ããã§ããã½ã¼ãããã¨ããè¨èã ããã§ã¡ãã¡ãã£ã¨èªåã§èª¿ã¹ãæãã javascriptã«ããããã¼ãªã³ã°ã¨ã¯F5åã¯XHRé£æã ãã³ã°ãã¼ãªã³ã°ã¨ã¯XHRã§ãã¼ã¿éä¿¡ã ãµã¼ãå´ã§ããããå¾ ã¤ã å¤æ´ãããã°ã¯ã©ã¤ã¢ã³ãã«æ»ãã ããªãæãèªã¿ã®ãã£ããææ¡ã§ãã ã³ã¡ãããªãè¨èãåºã¦ãã¾ããããã³ã°ãã¼ãªã³ã°ã¨ ä¼¼ããããªãã®ãã¨ãããã¨ã¿ããã Cometã¨Ajaxãå©ç¨ãããã£ãããµã¼ãã®å®è£ ãã¡ãã®ãµã¤ããããããããã£ãã§ãã ã¾ãçµå±ã®ã¨ããå½ããåããç¥ãã¾ãããã ã¯ã©ã¤ã¢ã³ããããµã¼ãã¸åãåãããªãã¨å§ã¾ããããã¨ã ããããã¾ãè¦ã¦ã®
ä»ã¾ã§FLASHçã使ããªãã¨åºæ¥ãªãã£ãã½ã±ããéä¿¡ã§ãã HTML5ã§åºæ¥ãããã«ãªãã¾ããã ã¾ããã®ãã¼ã¸è¦ã¦ã人ã¯èª¬æä¸è¦ã§ããããã詳細ãªèª¬æã¯å²æ æ¬æ ¼çã«ã¯socket.ioãªã©ãã¤ã³ã¹ãã¼ã«ãã¦ãã¨ããã®ãããã¾ãã PHPã ãã§ãµã¯ãã¨ä½é¨ãããæ¹ã¯ç¶ãã御覧ä¸ããã Saran Chamlingãããä½ã£ããWebSocket Exampleãããã¦ã³ãã¼ã http://www.sanwebe.com/downloads/50-websocket-example ãã£ããã·ã³ãã«ãª ãserver.phpï¼ãµã¼ããã¡ã¤ã«ï¼ã ãindex.phpï¼ã¯ã©ã¤ã¢ã³ããã¡ã¤ã«ï¼ã 2ã¤ã®ãã¡ã¤ã«ã解å ä»çµã¿çã«ã¯ ãserver.phpï¼ãµã¼ããã¡ã¤ã«ï¼ããã³ãã³ãã©ã¤ã³ã§å®è¡ãwhileã§ã«ã¼ã ãindex.phpï¼ã¯ã©ã¤ã¢ã³ããã¡ã¤ã«ï¼ãããã©ã¦ã¶ããå®è¡ ã¨ããæ
2012å¹´1æ2æ¥ è¿½è¨ ææ°ã®ãã©ã¦ã¶ã«å¯¾å¿ãããã¼ã¸ã§ã³ã®è¨äºãæ¸ãã¾ããã ä»åã¯WebSocketã®åå¼·ããã¦ã¿ã¾ãã ã¨ãããããµã¯ã£ã¨åããã¦ã¿ãäºãç®çã¨ãã¦ãã¾ãã®ã§ããã¾ãç´°ããäºã¯æ°ã«ããã«è¡ãããã¨æãã¾ãã æ¦è¦ ãããã®VPSã¨PHP5.3ã§WebSocketã®Echoãµã¼ãã¼ãæ§ç¯ããJavaScriptã§ãµã¼ãã¼ã«æ¥ç¶ãããã£ããã§ããç°¡åãªãµã³ãã«ãä½ã£ã¦ã¿ã¾ãã 次ã®æ§ãªè¨äºããããããè¦ã¦ããã®ã§ãä»åã¯å¯¾è±¡ãã©ã¦ã¶ãChromeã®ã¿ã¨ãã¾ããã http://www.publickey1.jp/blog/10/websocketfirefox_4opera.html ç°å¢ ãããã®VPS CentOS PHP 5.3 Chrome 10.0.628.0 dev åèï¼ãããã®VPSã«ã¤ã㦠å æ¥hetemlãããããã®VPSã«ãµã¼ãã¼ã移è¡ãã¾ããã
WebSocket API ã¯ãã¦ã¼ã¶ã¼ã®ãã©ã¦ã¶ã¼ã¨ãµã¼ãã¼éã§å¯¾è©±çãªéä¿¡ã»ãã·ã§ã³ãéããã¨ãã§ãããã®ã§ãããã® API ã使ç¨ããã¨ããµã¼ãã¼ã«ã¡ãã»ã¼ã¸ãéä¿¡ãããµã¼ãã¼ããè¿ä¿¡ããã¼ãªã³ã°ãããã¨ãªãå¿çãåä¿¡ãããã¨ãã§ãã¾ãã WebSocket API ã¯ãã¦ã§ãã½ã±ããæ¥ç¶ãä½æãã¦ä½¿ç¨ããããã®ãWebSocket ã¤ã³ã¿ã¼ãã§ã¤ã¹ã¨ WebSocketStream ã¤ã³ã¿ã¼ãã§ã¤ã¹ã¨ãã 2 ã¤ã®ç°ãªãã¡ã«ããºã ãæä¾ãã¦ãã¾ãã WebSocket ã¤ã³ã¿ã¼ãã§ã¤ã¹ã¯å®å®ãã¦ããããã©ã¦ã¶ã¼ã¨ãµã¼ãã¼ã®å¯¾å¿ãå å®ãã¦ãã¾ããããããèå§ã«ã¯å¯¾å¿ãã¦ãã¾ããããã®ãããã¢ããªã±ã¼ã·ã§ã³ãã¡ãã»ã¼ã¸ãå¦çãããããéããã¼ã¹ã§ã¡ãã»ã¼ã¸ãå°çããã¨ãã¡ãã»ã¼ã¸ããããã¡ã¼ã«ä¿åãããã¨ã§ç«¯æ«ã®ã¡ã¢ãªã¼ããã£ã±ãã«ãªã£ãããCPU 使ç¨çã 100% ã«ãªã£ã¦å¿çä¸è½
è¿ãå°æ¥WebSocketãRailsã§ä½¿ç¨ã§ããããã«ãªãã¨èãã¨ããããããã¯ã¿ããªèãä¸ãã£ã¦è奮ãã¾ãã ãããã ããªãã®ã¦ã¼ã¶ã¯ãããªããWebSocketã使ç¨ãã¦ãããã©ãããªãã¦æ°ã«ãã¾ãã ã ã¦ã¼ã¶ã¯ãâå¿«é©ãªãªã¢ã«ã¿ã¤ã Webã¢ããªâãæ±ãã¦ããã ãããããã¯ãâå¿«é©ã§ãã«ããç°¡åãªãªã¢ã«ã¿ã¤ã Webã¢ããªâãæ±ãã¦ããã ãªãã¬ã¼ã·ã§ã³ã¯ãâãããã¤ãã¹ã±ã¼ã«ã管çãç°¡åãªãªã¢ã«ã¿ã¤ã Webã¢ããªâãæ±ãã¦ããã ä¸è¨å ¨ã¦ã®è¦æãWebSocketãããªãã¦ãããã®ãªãç´ æ´ããããã¨ã§ããããã®å®è£ ã®è©³ç´°ã¯é«ãã³ã¹ãããããã¾ãã è¶ é«æ§è½ã§å ¨äºéãªã¯ã©ã¤ã¢ã³ãã¨ãµã¼ãéã®éä¿¡ã¯ãæ¬å½ã«ç§ãã¡ã«å¿ è¦ãªã®ãï¼ WebSocketã¯ãã¯ã©ã¤ã¢ã³ãã«æ å ±ãé ä¿¡ããããã®ç°¡åãªAPIã¨ãã¯ã©ã¤ã¢ã³ãããWebãµã¼ãã¸æ å ±ãéä¿¡ããããã®ç°¡åãªAPIãæä¾ãã¾ãã ãµã¼ã
The problem: Low latency client-server and server-client connections The web has been largely built around the so-called request/response paradigm of HTTP. A client loads up a web page and then nothing happens until the user clicks onto the next page. Around 2005, AJAX started to make the web feel more dynamic. Still, all HTTP communication was steered by the client, which required user interactio
WebSocketï¼ã¦ã§ãã½ã±ããï¼ã¯ãåä¸ã®TCPã³ãã¯ã·ã§ã³ä¸ã«åæ¹åéä¿¡ã®ãã£ã³ãã«ãæä¾ãããã³ã³ãã¥ã¼ã¿ã®éä¿¡ãããã³ã«ã®1ã¤ã§ãããWebSocketãããã³ã«ã¯ã2011å¹´ã«RFC 6455ã¨ãã¦IETFã«ããæ¨æºåããããWeb IDLï¼è±èªçï¼ä¸ã®WebSocket APIã¯ãå½åW3Cã«ããæ¨æºãããå¾ã«WHATWGã«å¼ãç¶ããã¦ããã WebSocketã¯HTTPã¨ã¯ç°ãªããããã³ã«ã§ãããã¨ãã«OSIåç §ã¢ãã«ã®ã¬ã¤ã¤ã¼7ã«ä½ç½®ããã¬ã¤ã¤ã¼4ã®TCPã«ä¾åãã¦ããã両è ã¯ç°ãªããããã³ã«ã§ããããRFC 6455ã§ã¯ãWebSocketã¯ãHTTPãããã·ã¨ä»²ä»è ããµãã¼ãããããã«ãHTTPã®443çªããã³80çªãã¼ãä¸ã§åä½ããããã«è¨è¨ããã¦ãããã¨è¿°ã¹ããã¦ããããã«ãHTTPãããã³ã«ã¨äºææ§ããããäºææ§ãå®ç¾ããããã«ãWebSocketã®ãã³ãã·ã§ã¤
å®ã¯ãã£ããåããWebSocketã®è©³ããä»çµã¿ã«ã¤ãã¦æ°ã«ãªã£ã¦ã¦ãéã«ä¸å¿µçºèµ·ãã¦èª¿ã¹ã¦ã¿ããä½ãã¨ã¦ãè¯ããã£ã½ãã ããããWebSocketã¨ã¯ Webã«ããã¦åæ¹åéä¿¡ãä½ã³ã¹ãã§è¡ãçºã®ä»çµã¿ãã¤ã³ã¿ã©ã¯ãã£ããªWebã¢ããªã±ã¼ã·ã§ã³ã§ã¯ãµã¼ãããä»»æã®ã¿ã¤ãã³ã°ã§ã¯ã©ã¤ã¢ã³ãã«æ å ±ã®éä¿¡ã¨ããããäºããã£ã¦ãä¾ãã°Facebookã®ãã£ããã¢ããªã¿ããã«å¤æ°ã®ã¯ã©ã¤ã¢ã³ããä¸ã¤ã®ãã¼ã¸ã«ã¢ã¯ã»ã¹ãã¦ã¦èª°ããã¡ãã»ã¼ã¸ãæ稿ããã¨ããããã®ä»ã®ã¦ã¼ã¶ã¼ã«éç¥ãããå ´åããã£ã¦ããããã£ãæã«åæ¹åéä¿¡ã®å¿ è¦æ§ãåºã¦ããã å ã ã¯Webã«ããã¦ã¯HTTPããéä¿¡ã®é¸æè¢ãç¡ãã¦HTTPã®ãã³ã°ãã¼ãªã³ã°ä½¿ã£ã¦ç¡çç¢çåæ¹åéä¿¡å®ç¾ããããã¦ããã ãã©ãæµç³ã«ç¡é§ãå¤ããããè¾ãããã£ã¦äºã§WebSocketã¨ãããããã³ã«ãä½ãããã WebSocketã«ããã¦ã¯ãTCPä¸ã§
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}