WebSocket 的 PHP 实现 - phpwebsocket
来源:互联网 发布:管理无线网络的软件 编辑:程序博客网 时间:2024/05/10 10:02
从名字上也可看出,这是一个 WebSocket 的 PHP 实现。
示例客户端代码:
1
var
host =
"ws://localhost:12345/websocket/server.php"
;
2
try{
3
socket =
new
WebSocket(host);
4
log(
'WebSocket - status '
+socket.readyState);
5
socket.onopen =
function
(msg){ log(
"Welcome - status "
+this.readyState); };
6
socket.onmessage =
function
(msg){ log(
"Received: "
+msg.data); };
7
socket.onclose =
function
(msg){ log(
"Disconnected - status "
+this.readyState); };
8
}
9
catch(ex){ log(ex); }
01
log(
"Handshaking..."
);
02
list(
$resource
,
$host
,
$origin
) = getheaders(
$buffer
);
03
$upgrade
=
"HTTP/1.1 101 Web Socket Protocol Handshake\r\n"
.
04
"Upgrade: WebSocket\r\n"
.
05
"Connection: Upgrade\r\n"
.
06
"WebSocket-Origin: "
.
$origin
.
"\r\n"
.
07
"WebSocket-Location: ws://"
.
$host
.
$resource
.
"\r\n"
.
08
"\r\n"
;
09
$handshake
= true;
10
socket_write(
$socket
,
$upgrade
.
chr
( ),
strlen
(
$upgrade
.
chr
( )));
- WebSocket 的 PHP 实现 - phpwebsocket
- php基于websocket实现的在线聊天室
- PHP 简单实现webSocket
- PHP 简单实现webSocket
- php的websocket
- php 异步websocket客户端实现
- WebSocket的java实现
- go的websocket实现
- 简单的websocket实现
- websocket的Java实现
- 嵌入式WebSocket的实现
- websocket客户端的实现
- websocket心跳的实现
- WebSocket聊天室的实现
- java WebSocket的实现以及Spring WebSocket
- 利用Swoole实现PHP+websocket 聊天室
- 利用Swoole实现PHP+websocket 聊天室
- websocket+php实现前后端实时通信
- Spring 框架的设计理念与设计模式分析
- 重拾ssh之hibernate配置
- HDU 1873 看病要排队 优先队列
- Android Gallery获取滑动停止的位置
- Linux下内存释放问题
- WebSocket 的 PHP 实现 - phpwebsocket
- poj_1111Image Perimeters
- 主函数 main WinMain _tmain _tWinMain 的区别
- Fiddler (数据抓包)跟踪监控android数据包工具使用
- WebKit Layout (布局)
- Ubuntu 12.10升级
- call
- error C2664: MessageBoxW不能将参数2const char*转换为LPCWSTR的解决办法
- a utility to compare date diff and date advance^_^