I’m working on a script that a server posts to us and we post to a server and theoretically is supposed to receive a response from the server and reply back to the server that posted to us. However sometimes the server I’m posting to doesn’t respond. The big problem is the server that posted to us will assume the transaction went through successfully unless it hears otherwise. So essentially I need a way to send a response back to the first server if I never hear back from the server I’m posting to. I think register_shutdown_function could work for me but I don’t know how to set that up so it only runs on error or whatever.
Thanks in advance
register_shutdown_function()should work for you. Just use a global variable to determine whether the remote server responded or not:This means that
$completewill still be false if the code which posts to the remote server does not complete, so you can just check the truthyness of$completein the function that fires on shutdown.