Reputation: 35
hello I was wondering if I can run my PHP
socket
server on the browser I have a simple code
$host = "0.0.0.0";
$somthing= 0;
$sock = (AF_INET, SOCK_STREAM, 0);
socket_listen($sock);
while(true)
{
//do somthing
}
at the moment m using cmd to run the server can I use my web browser to do this so basically what I need is my browser to run the server and get replies from a client I can setup the client if someone can guide me on what to do so I can make it run on the server
Upvotes: 0
Views: 647
Reputation: 374
Your browser can run your server script, look for "WAMP" solution (Windows, Apache, MySQL (that you don't need in such case), PHP like wampserver !
For the second part, your client, you are going to need to use other technology. Ideally, I would recommand looking to use JavaScript "websocket".
Be aware, a PHP script can run for a limited amount of time by default, you can extend it.
I could also say that running the server script into a browser isn't ideal, you should run it in command line to avoid the script to stop running if you close the page (and also to avoid running the script more than once !).
Upvotes: 2