A simple PHP socket serverwhich doesn’t require process forking.
Comes with a few basic commands, feel free to use from GitHub.
Trawling through sold old project files, I came across a PHP socket server a wrote in 2014. I thought I’d post the code here if anyone was looking to work on a similar project. Source code on GitHub.
The script loops through all clients waiting for input to handle, clients can connect using a Telnet console. Defaults to listen on all interfaces over port 2014. This can be changed in the index.php by editing the following code:
Server::start( '0.0.0.0', 2014 );
It currently has the following commands available to connected clients:
Sends a string to server, to be sent to all connect clients.
Sends a string to server to echo back.
Returns server up time and a list of client connection details.
Closes the client connection.
Disconnects all clients and shuts down the server.
Returns current server time.