Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Closing an HTTP connection
August 29, 2005, 2:16 pm
rate this thread
I need some help here.
Is it possible to close an HTTP connection in the middle of a php
This is a web page
I know that the shell_exec statement will take a long time to complete.
But I also know that no further content needs to be delivered to the
user. Is it possible to close the connection so that the browser is not
hanging around waiting for more information, but the php script keeps
running on the server?
Thanks for any help.
Re: Closing an HTTP connection
Won't work - you haven't dissocciated the new process from the parent.
(Might work on a non-unix system). The webserver won't send an EOF until
the chid process terminates. You could call it from a function registered
using register_shutdown_function() to run after the socket is closed but
that's still messy as the the webserver process hangs around to wait for it
You can create a separate process group easily using the 'at' command.
$run_in_background=`echo $name_of_script | at now`;
If the above didn't answer your question (there are instances where you
might want to disconnect from the browser but continue with the current
thread of execution) then repost - there's an answer to this as well, but
it really starts getting complicated and you need to start working with
proxy scripts and sockets.