I would like to implement communication between two processes on the server via php tools to implement long-pooling.
For this purpose, php was compiled with the keys --enable-sysvsem --enable-sysvshm --enable-sysvmsg
It is assumed that this will work as follows: while the client is on the page, asynchronous requests are sent to it using ajax means. The server side script opens the message queue using msg_get_queue . And listening to her for a certain amount of time, for example, 2 minutes. After that, the process dies off and a new request is sent. Upon receipt of the same data, they are sent to the client.
However, a number of questions arose:
Does the set_time_limit function affect the receive_messages function call, or is it considered systemic because it works through SysV shared memory? Because the standard read_message function has no timeout parameter, which is very disappointing.
-Is it possible to configure the script to perform certain actions before disconnecting? I would very much like to "turn off" the queue, which will no longer be used. If not, is it possible to somehow “shoot” the queues from outside, with which no process worked for a long time?
PS do not offer frameworks.


PPS If you know that long-poll can be implemented better \ easier \ more conveniently - you can be proud of that, tell me right away whether this option will load the server on which the Apache and php machines are running and how convenient it is to integrate such a solution into an existing one the system.

  • Describe your problem (task). What you wrote here is utter nonsense. - ArchDemon
  • It is required to implement asynchronous dynamic update of the page content. As one of the solutions, php semaphore functions are considered. The sender must notify the "listener" (if several tabs are open - all) about the action taken. I want to understand how critical resource management is here, that is, if after using the resource has not been closed - will it have time for it, after which it will self-destruct? And what can be done to ensure that the situation described above does not arise. It is also interesting how you can implement wait for a thread with no wait , 0shn1x
  • @ArchDemon Well, nothing to write? Next time then you don't have to show off - 0shn1x
  • And what ajax did not suit you? - ArchDemon
  • @ArchDemon ajax is used to transfer data to the server \ from the server asynchronously. But from client to server and from server to client. And I need to transfer data about the event that caused one client to another client. It is clear that with ajax I will transfer the data to the server, but further - they should get into another php script, which will send them back through the same ajax. I believe that this is the task for which shared memory was created. - 0shn1x

0