Is it possible to implement an event driven program in PHP?
Something like javascript.
As an example, try opening socket(open_socket) and running a few other command(do_something_else) instead of waiting for a response to the socket request. After receiving a success response, execute callback_execute .
//-------------------------------------------------------------------- public function open_socket(){ $this->socketResource = fsockopen($this->nodeIp,$this->portNumber); } public function callback_execute(){ fputs($this->socketResource,$command); } public function do_something_else{ xxxxx } //-------------------------------------------------------------------- Non_blocking_function($obj->open_socket(),$obj->callback_execute()); $obj->do_something_else();
source share