downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

stream_set_timeout> <stream_select
Last updated: Fri, 14 Aug 2009

view this page in

stream_set_blocking

(PHP 4 >= 4.3.0, PHP 5)

stream_set_blockingConfigure le mode bloquant d'un flux

Description

bool stream_set_blocking ( resource $stream , int $mode )

stream_set_blocking() configure le mode bloquant du flux stream .

Cette fonction fonctionne pour tous les flux qui supportent le mode non-bloquant (actuellement, les fichiers et les flux de sockets).

Liste de paramètres

stream

Le flux.

mode

Si mode vaut 0, stream sera configuré en mode non-bloquant, et s'il vaut 1, stream sera configuré en mode bloquant. Cet appel affecte les fonctions telles que fgets() et fread() qui lisent dans des flux. En mode non-bloquant, la fonction fgets() s'exécute juste après son appel, alors qu'en mode bloquant, elle attendra des données.

Valeurs de retour

Cette fonction retourne TRUE en cas de succès, FALSE en cas d'échec.

Historique

Version Description
4.3.0 Avant PHP 4.3, cette fonction ne fonctionnait que sur les flux utilisant des sockets.

Notes

Note: Cette fonction s'appelait jadis set_socket_blocking() puis socket_set_blocking() mais leur usage est déconseillé.

Voir aussi



stream_set_timeout> <stream_select
Last updated: Fri, 14 Aug 2009
 
add a note add a note User Contributed Notes
stream_set_blocking
galvao at galvao dot eti dot br
15-Dec-2006 04:58
Please notice that this function will not work as for PHP 5.2.0 at least on Win32 systems. It probably won't work on Linux boxes either.

PHP just ignores the function and blocking remains active.

For more information take a look at Bug #36918.
MagicalTux at ookoo dot org
08-Sep-2006 06:13
When you use fwrite() on a non-blocking stream, data isn't discarded silently as t dot starling said.

Remember that fwrite() returns an int, and this int represents the amount of data really written to the stream. So, if you see that fwrite() returns less than the amount of written data, it means you'll have to call fwrite() again in the future to write the remaining amount of data.

You can use stream_select() to wait for the stream to be available for writing, then continue writing data to the stream.

Non-blocking streams are useful as you can have more than one non-blocking stream, and wait for them to be available for writing.
t dot starling at physics dot unimelb dot edu dot au
08-Sep-2005 11:02
Warning: if you write too much data to a stream in non-blocking mode and fill the buffer, the excess will be silently discarded. Observed in PHP 4.4.0 under linux.

stream_set_timeout> <stream_select
Last updated: Fri, 14 Aug 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites