I'm trying to build a little command-line IRC client in PHP because I'm getting sick of all those clients having you click through twenty GUI popups/windows to connect to a new server.
Everything is working so far, but I'm stuck with the main loop that sends my input commands/messages to the server and receives the new data from it.
As PHP isn't very multi-task-friendly I have two autonomous PHP scripts running at the same time:
The input reader where I can enter my messages - it stores the current message in a text file. The server listener/writer which receives new data and reads and clears the text file where the input reader stored my current command in.
However fgets()
which I use to read new data from the server pauses the script waiting until something new arrives
.
So the input text file can't be read out until something new arrives from the server, which is not good.
- Is there some special function/option to help me out?