If I understand what you have written correctly, the web server is forwarding requests to your C++ program, and you want a PHP application to read the data by making a web request to the web server, which in turn forwards the request to the C++ program for serving the response.
Here are three ideas for improving the speed of this setup:
Consider using a streaming parser to parse the data read from the socket. This will allow your PHP application to begin consuming and processing the data before all of the data is read from the socket.
Many JSON libraries do not offer streaming parsing APIs (see Is there a streaming API for JSON?). For example, PHP's built-in JSON APIs do not. But, see Incremental JSON parsing in php.
PHP has a built-in XML pull parser, XMLReader. If your C++ program generated XML data, you could use an XMLReader in PHP to parse the XML incrementally, meaning that your PHP application would not need to wait until the data was fully downloaded.
If your C++ program is reading JSON from a file and sending the file's contents over the socket, consider using zero-copy I/O. See also vmsplice().
If the C++ program and your PHP application are running on the same server, you could use a shared memory segment. This would eliminate the need for transferring the data over a socket, because the C++ program and PHP application would both have access to a segment of memory. The C++ program would write all of the data into the shared memory segment, and then the PHP application would read the data.
See PHP's Semaphore functions for more information.