websocket服务器握手协议

websocket服务器握手协议,第1张

websocket服务器握手协议

测试网页代码如下

<!DOCTYPE html>
<html>
<head>
<title>测试 websocket 世界最简单案例</title>
</head>
<body>
<script>
var ws = new WebSocket("ws://127.0.0.1:8001/index.html"); ws.onopen = function(){
alert("open");
ws.send("WebSocket");
};
ws.onmessage = function(ev){
alert(ev.data);
};
ws.onclose = function(ev){
alert("close");
};
ws.onerror = function(ev){
console.log(ev);
alert("error");
};
</script>
</body>
</html>

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/587842.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存