File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Server socket with php
2- php server socket & ; HTML 5 WebSocket
2+
3+ Simple php socket [ Server] for webSocket HTML5
4+ <br />
5+ ## Edit /js
6+ don't forget to edit main.js file with <code >ws://YOUR_DOMAIN: PORT /</code >
7+ <br />
8+ ## Edit /main.php
9+
10+ <code >
11+ $socket = new ServerSocket(SAME_DOMAIN_IN_JS, SAME_PORT);
12+ </code >
13+ <br />
14+ ## run
15+ open your terminal and go to the folder and type <code >php .\main.php</code >,
16+ <br />you should see in the terminal:<br />
17+ <pre >
18+ <code >
19+ ------ Server running DOMAIN:PORT ------
20+ ----- Waitting for client to connect 1/2 ----
21+ </code >
22+ </pre >
23+
24+ open your browser http://DOMAIN and the client should connect to the server [ Client 1] .<br />
25+ open a second tab (or new window browser) and type the same url, the client should connect [ Client 2] .<br />
26+ <br />
27+ in the browser you should see (Socket is open) in both tabs [ Client 1, Client 2] .<br />
28+ Start sending and reciving the messages between the clients.<br />
29+ <br />
30+ ## important
31+ don't forget to enable the php extenstion [ socket] .
You can’t perform that action at this time.
0 commit comments