我刚刚阅读了有关 Web 套接字的内容并编写了这个简单的客户端 Java 脚本。但即使我在 Chrome 浏览器上运行并且我不知道 FAULT 是什么,它也没有给我任何输出?可能是 google.com 不支持 Web 套接字?
<!DOCTYPE html>
<html>
<head>
<title>Web socket Experiment</title>
<script type="text/javascript">
function callWebSocket() {
var socket = new WebSocket("ws://www.google.com");
socket.onopen = function () {
alert("Hello, Connected To WS server");
};
socket.onmessage = function (e) {
alert("The message received is : " + e.data);
};
socket.onerror = function (e) {
alert("An error occured while connecting... " + e.data);
};
socket.onclose = function () {
alert("hello.. The coonection has been clsoed");
};
}
</script>
</head>
<body>
<input type="button" value="Open Connecton" onclcik="callWebSocket()" />
</body>
</html>
请帮忙..
谢谢斯内哈
_