tl;dr: What is the best approach to keep a PHP Socket unblocked by MySQL Operations?
Basic Goal: Have a PHP+JAXL (XMPP) Socket listen, read and write via a persistent TCP Connection to Googles CCS GCM Server. This was accomplished using this CODE.
- Now I need to Process Data (mostly MySQL) without blocking the Socket.
What have i thought of:
1: Have the Socket and the DB connection in two different PHP Threads. Communication could work via JobQueues. Implementations I found based on Geaman, Resque, BeanStalkD. These work however, mostly with a Master and Worker thread, so no bidirectional communication.
2: Implement a basic Queue as a global? Variable, Read Jobs from the DB thread, and put them back into another queue. (No idea whether smth lk this is possible)
3: Fork child processes like proposed in here. I would then have to open a DB connection everytime I fork, which I thought I could avoid in some way. Also, how to call send() from child?.
Hard Parts:
1: Two-way communication required: DB Thread has to send results to Socket
2: should work on Shared Hosting, e.g no Gearman, Redis installation.
also: no PHP skills
What am I asking?:
What is needed to not block the Socket, and what not?
Which approach is suited for my needs, especially when my DB-Thread has to assign jobs to the Socket ("send xy")?
What am I understanding wrong here?
As you can see I lack the basic understanding, any guidance is very appreciated. Thanks alot.