Setting the STREAM_CLIENT_PERSISTENT flag when creating a stream prevents connection downtime. Inside the flag, stream_socket_client() makes a call to pfsockopen() ( doc ) instead of fsockopen() ( doc ).
Constancy of communication is limited by the process of the server on which the connection was opened. When your script exits and you call it again, there can be no guarantee that the same process is processing your request - in this case, another connection will be opened. Enabling a connection in $_SESSION for sharing will not work.
source share