orionmetrics
New member
Hi, I have developed a simple prototype application using ExeOutput for PHP which will be used to link a client’s commercial reporting package with a remote database using standard socket ports - using localhost on port 9000.
Client reporting package <=> ExeOutput Application 127.0.0.1:9000 <= web api port 80 <= server mysql port 3306
The application itself works fine, accept when I go to terminate the application. It works by having a loop of socket_listen, socket_read and socket_output to respond to client requests, unfortunately when it goes to the socket_read command,and I then terminate the application, in the background it is still listening… and hence doesn’t shutdown correctly (not a loop issue as such). I know there are built in variables for testing if the application has closed, but in this scenario it isn’t of much use as the program waits on one command for response from the client application (which may never come if the client application is shut down as well). In traditional programming, the solution would be a call back routine, but php sockets doesn’t seem to support call backs.
I would be grateful if anyone had an idea how to shutdown the application completely when it is waiting on a socket_listen / socket_read.
One idea of a possible solution, but not sure how to implement it (even if possible), is if I can somehow override the ExeOutput exit command so it calls a php function or script first, just prior to exiting - this is so that a secondary exit php script could send a packet to the main applications socket_read, set a variable that the application has finished to prevent the main application re-looping (in fact already has the global variable test in place for the standard exit, which is why this whole problem isn’t a loop issue), and then exits the application as normal. Is it therefore possible to get ANY exit call to call php scripts/functions first, before actually attempting to shutdown the application ?
Thanks for any help given.
Client reporting package <=> ExeOutput Application 127.0.0.1:9000 <= web api port 80 <= server mysql port 3306
The application itself works fine, accept when I go to terminate the application. It works by having a loop of socket_listen, socket_read and socket_output to respond to client requests, unfortunately when it goes to the socket_read command,and I then terminate the application, in the background it is still listening… and hence doesn’t shutdown correctly (not a loop issue as such). I know there are built in variables for testing if the application has closed, but in this scenario it isn’t of much use as the program waits on one command for response from the client application (which may never come if the client application is shut down as well). In traditional programming, the solution would be a call back routine, but php sockets doesn’t seem to support call backs.
I would be grateful if anyone had an idea how to shutdown the application completely when it is waiting on a socket_listen / socket_read.
One idea of a possible solution, but not sure how to implement it (even if possible), is if I can somehow override the ExeOutput exit command so it calls a php function or script first, just prior to exiting - this is so that a secondary exit php script could send a packet to the main applications socket_read, set a variable that the application has finished to prevent the main application re-looping (in fact already has the global variable test in place for the standard exit, which is why this whole problem isn’t a loop issue), and then exits the application as normal. Is it therefore possible to get ANY exit call to call php scripts/functions first, before actually attempting to shutdown the application ?
Thanks for any help given.
Last edited: