Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The WebSocketServer class you have linked launches said Server on the port given while creating the object. Note that this port cannot be the same as your webserver due to obvious reasons.</p> <p>The javascript side needs to open a WebSocket to that server, assuming that ServerEventsDispatcher internally opens a new WebSocket on the ws://:12345/ you need to add the host name or ip address of the server running the WebSocketServer with the correct port number there.</p> <p>So, say the WebSocketServer runs on someserver.domain.com on port 81 (since 80 is most likely used by IIS):</p> <pre><code>var server = new ServerEventsDispatchet("someserver.domain.com:81"); </code></pre> <p>Looking at the code for that javascript class it actually opens a WebSocket using the address directly; so you could also use <code>ws://someserver.domain.com:81</code> there if you want to specify the protocol (or wss for SSL).</p> <p>Edit in followup of your edit: I'd use the public address for your server in that WebSocketServer class; as it will try to bind on it:</p> <pre><code>socket_bind($this-&gt;master, $this-&gt;address, $this-&gt;port) or die("socket_bind() failed"); </code></pre> <p>see also: <a href="http://nl3.php.net/manual/en/function.socket-bind.php" rel="nofollow">http://nl3.php.net/manual/en/function.socket-bind.php</a></p> <p>In addition to your latest edit:</p> <p>you shouldn't add the path to your php script. When you open your PHP script, it should try to open up that WebSocket server; but the websocket server will just run at <code>"ws://&lt;servername&gt;:&lt;port&gt;"</code>. So in the javascript you can use that as address, and then browse to the php script in your browser for the test program.</p> <p>-- Edit for server use --</p> <p>Since this would become too long/unreadable in a comment; according to the site you have to use a php commandline to actually launch the server class:</p> <p>"Open a terminal window (Command line on windows) and navigate to your project directory. Execute the script with PHP and if all went to plan you should get the following message:"</p> <pre><code>$ php -f server.php Server Started : 2010-05-26 22:40:03 Listening on : localhost port 12345 Master socket : Resource id #5 </code></pre> <p>When that's done; the server should be up and listening. You can then connect to that server using the WebSocket in javascript with the websocket url as said above :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload