The php Function Stream_Set_Blocking
The php function stream_set_blocking is part of the Stream class which is a generalized way to handle file, network and data compression operations. It is an asynchronous mechanism that makes it possible to start, pause and resume the execution flow of an isolated portion of your program, essentially creating a virtual thread that only lives within one PHP process. This is different from regular threads that are managed by the operating system and that live in multiple processes or even in a separate kernel thread.
This function has a single argument, mode, which can be either blocking or non-blocking. If mode is 0, the given stream will be switched to non-blocking mode, if mode is 1 it will be returned to blocking mode. This affects calls like fgets() and fread() which will return right away if the stream is readable, or block if it is not.
tv_sec and tv_usec are timeout parameters in microseconds. If they are set to 0 stream_select() will never block, instead it will poll the streams for data and return as soon as any of them change status (or if the call is interrupted by an incoming signal). If tv_sec or tv_usec is not set, a timeout of -1 seconds will be used which will mean that stream_select() will block indefinitely until an event on one of the watched streams occurs. This can be quite expensive for loops, so it is a good idea to use tv_sec and tv_usec together.