Pregunta

I am building a php service that listens for udp broadcasts, as part of the project I would like to be able to send commands to that same script. Normally I would use some type of polling and mysql, but this project lives in flash memory so I'm trying to limit my writes as much as possible... The udp broadcast listener works great and runs as a daemon in ubuntu, is there a way for me to pass run time arguments to it after the service has started?

Edit:

This question is about passing arguments to a script that is already running.

¿Fue útil?

Solución 2

So as far as I can tell this isn't really possible the way I was hoping. The 2 solutions I can use are setting an outside variable (in the DB or flat file) and checking for it periodically, or since this is actually listening for a UDP broadcast I can just send out a UDP with the information I would like to pass to the script. While neither of these are particularly elegant, they both work.

On a side note, don't build UDP servers in PHP. This was really just a proof of concept, but is horribly inefficient. While using php to handle the data in the broadcast seems to work well, it is definitely preferable to use Python or Java for the listener itself and pass the data to a script.

Otros consejos

Either let you Daemon keep a state of the runtime arguments and have it accept commands that change the runtime arguments it passes to the php script. Or have an ini or json file with the runtime arguments that every time the php script starts it re-reads. Once you change the file all subsequent script calls will use the new arguments.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top