Thread: Returning PHP output to client but keeping thread open
hi,
want able keep thread running in server, somehow , send ajax posts it.
when php executes, returns stdout when finishes execution. need program holds open infinite loop , dependant on script sends back, user can make choices send posts allow perform actions. reason opens socket , needs read/write xml socket. need time out after minute.
thinking writing cgi program, dont know best way deal issue. languages competent c/c++ java , php.
prefer use php , java 2 languages know best, brush dust off c++ text , use if necessary although libraries limited.
think?
i have written such similar script. user can render minecraft worldmap , see progress of tool (c10t). i'm using infinite loop checking if connection has been closed , if not reading current output c10t, calculating has been sended , sending rest. ob_flush() , flush() send output after every loop.
got output c10t have called before loop script proc_open. calls proc_open c10t , storing output in file. @ least ensures correct closing of opened processes.
don't forget let loops sleep little after every execution not waste huge amount of cpu time. advantage solution not dependent of javascript may not activated in browser of client.
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Returning PHP output to client but keeping thread open
Ubuntu
Comments
Post a Comment