为什么WebSockets只能与websocket.org一起使用

Why does WebSockets only work with websocket.org and not through localhost? All I get is undefined from javascript. What's so special about ws://websocket.org?

WebSocket connection to 'ws://localhost/includes/php/UnitTest/WebSocketTest.php' failed: Error during WebSocket handshake: Unexpected response code: 200

I have tried all port numbers ws://localhost:80/ same problem

<script language="javascript" type="text/javascript">
    var ws = new WebSocket("ws://127.0.0.1:80/includes/php/UnitTest/WebSocketTest.php");
    ws.onopen = function() { alert("open");}
    ws.onerror = function(e){alert(e.reason+ " " + e.code);}

</script>

I am reading two books The Definitive Guide to HTML5 WebSocket and O'Reilly WebSocket and none of them talk or point out this problem, I thought this was all standard stuff by now?

Can you help?

Your server side must be ready to accept WebSocket connections.

In PHP you can use Ratchet for this. You can find a basic tutorial here: http://socketo.me/docs/hello-world