PHP HTML5 WebSocket How to initialize, always fail

Source: Internet
Author: User
Tags php server
Download the demo has a problem, my implementation is basically like this

The first is the service-side server.php
http://code.google.com/p/phpwebsocket/source/browse/trunk/%20phpwebsocket/server.php
Client-side client.html
Http://code.google.com/p/phpwebsocket/source/browse/trunk/%20phpwebsocket/client.html

Run the server to wait before running the client:
var host = "ws://localhost:12345/websocket/server.php";//This path is the location of the file, do not know right
Socket = new WebSocket (host);
This socket will go wrong and alert (socket) is displayed as [object WebSocket]
But tip:
Firefox cannot establish a connection to the ws://localhost:12345/socket/test/server2.php server.
Socket = new WebSocket (host);//No

(Apache FF11.0)
Please expert guidance:
The results you want to achieve are:
Http://websocket.org/echo.html


Reply to discussion (solution)

1. Browser support Required
2, need to the slogan to
3. Need code Error

function WebSocket ($address, $port) {...}

+--------------------------------------+
http://code.google.com/p/phpwebsocket/source/browse/trunk/%20phpwebsocket/server.php
The WebSocket () function in this file transmits 2 parameters, one address, one port
No port, run to here Socket_bind ($master, $address, $port);
will be an error!

1. Browser support Required
2, need to the slogan to
3. Need code Error


You said three points is fine, I just don't understand the meaning of the URI
For example, Server WebSocket (uri1,12345);//uri1 is localhost
So what kind of Uri does my client build a connection to the server?
Is it localhost or localhost/test/server.php?

function WebSocket ($address, $port) {...}

+--------------------------------------+
http://code.google.com/p/phpwebsocket/source/browse/trunk/%20phpwebsocket/server.php
The WebSocket () function in this file is to transmit 2 ...

No, but there's a URI inside.
However, I changed it a bit, and immediately I was disconnected,
Firefox cannot establish a connection to the ws://localhost/test/server.php server.
Socket = new WebSocket (host,12345);
Port to see a bit, is also the listing state, what is this host, the host address or file location, the client
Give WebSocket a parameter like this. localhost:12345

Solved, explain, ie to 10 only support, evil
The agreement has been revised, draft10.
Be sure to pay attention to the handshake protocol, which is fairly simple
Transmission communication is transmitted in frames, which is a little difficult to study.

Solved, explain, ie to 10 only support, evil
The agreement has been revised, draft10.
Be sure to pay attention to the handshake protocol, which is fairly simple
Transmission communication is transmitted in frames, which is a little difficult to study.



What is this host, the host address or the file location, the client

May I ask how you solved the problem?

How to write the target address in JavaScript, how to put the file path on the server

Reference to the 5 floor of the reply:

Solved, explain, ie to 10 only support, evil
The agreement has been revised, draft10.
Be sure to pay attention to the handshake protocol, which is fairly simple
Transmission communication is transmitted in frames, which is a little difficult to study.


What is this host, the host address or the file location, the client

May I ask how you solved the problem?

How to write the target address in JavaScript, how to put the file path on the server


Host address, in the final analysis he is the socket, he does not call the file
Be aware of version and compatibility issues
If there is key1 and Key2 is the old version, the new browser can not be used, depressed

Landlord, now I am also doing this, in it. Let me ask you something.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.