Hack #71 Build a Blazing-Fast WebSocket Server with Node.js and the ws Module

・動作の確認方法

準備

$ unzip chapter9jp.zip
$ cd chapter9jp/hack71
$ npm install ws
(node install -g ws を実行する場合はroot/Administrator権限が必要)

「図9-6 ターミナルを使って、Kaazing エコーサーバにリクエストする」の確認

$ wscat -c ws://echo.websocket.org
connected (press CTRL+C to quit)
> echo me
< echo me

(終了はCtrl-C) 

「単純なサーバを作成し、wscat を使ってサーバに接続す」の確認

[term1]$ node server-jp.js

[term2]$ wscat -c ws://localhost:8080 -p 8
connected (press CTRL+C to quit)
< 私はwsサーバから送られたメッセージです
> テスト中

[term1]$ node server-jp.js 
受信: テスト中

(終了はCtrl-C) 

「単純なクライアントの作成」の確認

$ node client-jp.js
受信: 私はwsクライアントからのopen EVENTです