您的位置:首页 > 运维架构 > Shell

Websocket On Bash

2014-01-18 02:02 260 查看
echo -ne "HTTP/1.1 101 Switching Protocols\r\n" >> resp

echo -ne "Upgrade: websocket\r\nConnection: Upgrade\r\n" >> resp

echo -ne "Sec-WebSocket-Accept: key\r\n" >> resp

echo -ne "\r\n" >> resp

[Server] { coproc P { nc -l 8888; } >&3; } 3>&1

[Client] var ws = new WebSocket("ws://localhost:8888/echo");

[Server] echo -n ${key}258EAFA5-E914-47DA-95CA-C5AB0DC85B11 | openssl dgst -sha1 -binary | base64

[Server] e /tmp/resp

[Server] cat /tmp/resp >&${P[1]}

[Client] ws.send("shit")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: