Chapter 7. Implementing Socket IPC and WebSocket Server/Client
In the previous chapter, we had a sneak peek at the application we're about to build in this chapter. We already know that we'll use the PHP Streams API for interprocess communication. We'll also write WebSocket servers and, later, a simple WebSocket client. We also emphasized the importance of understanding how event loops work in an asynchronous and non-blocking application, and this will apply for both server and client applications in this chapter.
This chapter will also be very source code-intensive, so we'll split it into three smaller sections covering three different applications:
Server Manager application: This is the application we'll run when testing this whole project. It'll spawn subprocesses and communicate with them via Unix socket streams (wrapped with the PHP Streams API). Each subprocess represents a single WebSocket server that listens to a specific port.
WebSocket Server application: This is a single instance...