//code
<Html>
<head>
<script type='text/Javascript'>
function test(){
alert("hi");
}
function ws(){
if ("WebSocket" in window){
alert("webSocket ok");
var sock = new WebSocket('ws://node.remysharp.com:8001');
sock.onopen = function(){
alert("conn ok");
}
sock.onclose = function(){
alert("conn close");
}
sock.onmessage = function(evt){
alert("recv: "+evt.data);
}
sock.send("{'hi'}");
}else{
ALERT("SLEEP");
}
}
</script>
</head>
<body>
<button onclick='ws();'>click Me</button>
</body>
</Html>
//end
使用tcp 以後可以詳細研究一下