diff --git a/reference/stream/functions/stream-get-options.xml b/reference/stream/functions/stream-get-options.xml new file mode 100644 index 0000000000..b9d7251f94 --- /dev/null +++ b/reference/stream/functions/stream-get-options.xml @@ -0,0 +1,39 @@ + + + + + stream_get_options + Retrieve options for a stream/wrapper/context + + + Description + + boolstream_get_options + resourcestream|context + + + Returns an array of options on the specified stream or context. + + + + + diff --git a/reference/stream/functions/stream-select.xml b/reference/stream/functions/stream-select.xml new file mode 100644 index 0000000000..f41cf920bb --- /dev/null +++ b/reference/stream/functions/stream-select.xml @@ -0,0 +1,161 @@ + + + + + stream_select + Runs the equivalent of the select() system call on the given + arrays of streams with a timeout specified by tv_sec and tv_usec + + + Description + + intstream_select + resource&read + resource&write + resource&except + inttv_sec + inttv_usec + + + The stream_select function accepts arrays of streams and + waits for them to change status. Its opperation is equivalent to that of + the socket_select function except in that it acts on streams. + + + The streams listed in the read array will be watched to + see if characters become available for reading (more precisely, to see if + a read will not block - in particular, a stream resource is also ready on + end-of-file, in which case an fread will return + a zero length string). + + + The streams listed in the write array will be + watched to see if a write will not block. + + + The streams listed in the except array will be + watched for exceptions. + + + + On exit, the arrays are modified to indicate which stream resource + actually changed status. + + + + You do not need to pass every array to + stream_select. You can leave it out and use an + empty array or &null; instead. Also do not forget that those arrays are + passed by reference and will be modified after + stream_select returns. + + + Example: + + 0) { + /* At least on one of the streams something interesting happened */ +} +]]> + + + + + Due a limitation in the current Zend Engine it is not possible to pass a + constant modifier like &null; directly as a parameter to a function + which expects this parameter to be passed by reference. Instead use a + temporary variable or an expression with the leftmost member being a + temporary variable: + + + + + + + The tv_sec and tv_usec + together form the timeout parameter. The + timeout is an upper bound on the amount of time + elapsed before stream_select returns. + tv_sec may be zero , causing + stream_select to return immediately. This is useful + for polling. If tv_sec is &null; (no timeout), + stream_select can block indefinitely. + + + On success stream_select returns the number of + stream resorces contained in the modified arrays, which may be zero if + the timeout expires before anything interesting happens. On error &false; + is returned. + + + + Be sure to use the === operator when checking for an + error. Since the stream_select may return 0 the + comparison with == would evaluate to &true;: + + + + + + + + Be aware that some stream implementations need to be handled very + carefully. A few basic rules: + + + + You should always try to use stream_select + without timeout. Your program should have nothing to do if there is + no data available. Code that depends on timeouts is not usually + portable and difficult to debug. + + + + + If you read/write to a stream returned in the arrays be aware that + they do not necessarily read/write the full amount of data you have + requested. Be prepared to even only be able to read/write a single + byte. + + + + + + + See also + stream_set_blocking + + + + +