The php Function Stream_Is_Local()
The php function stream_is_local() allows you to check whether a given file descriptor is local or not. This can be very useful, especially when working with streams.
Streams in PHP provide direct access to the language's standard input and output, as well as temporary memory and disk-backed file streams. They can be read and written using a variety of operations, such as fread() or fwrite().
A filtered stream can be used to carry out string replacement or other operations on each chunk of data that comes into the system, for example adding a title in front of every name in a list of names, or sending an email alert when a certain phrase appears (like 'green bottles sitting on a wall'). You would implement a filter by extending php_user_filter.
When reading or writing to a stream you should always close it after you are done. This prevents accidental overwriting of other files or other problems.
The parameter tv_sec and tv_usec determine how long stream_select will wait for an event on one of the watched streams. If tv_sec or tv_usec is zero, stream_select will return immediately after each polling cycle without waiting for anything. Otherwise it will block until an event on a watched stream occurs, or until the timeout expires and the call is interrupted by a signal.
Be aware that a 0 timeout value is not a good idea in a loop, as it can cause your script to run into excessive CPU load. You should use a higher value, such as 5 seconds.