stream_set_blocking

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

stream_set_blocking為資源流設置阻塞或者阻塞模式

說明

stream_set_blocking(resource $stream, bool $enable): bool

stream 設置阻塞或者非阻塞模式。

此函數適用于支持非阻塞模式的任何資源流(常規(guī)文件,套接字資源流等)。

參數

stream

資源流。

enable

如果 enablefalse,資源流將會被轉換為非阻塞模式;如果是 true,資源流將會被轉換為阻塞模式。 該參數的設置將會影響到像 fgets()fread() 這樣的函數從資源流里讀取數據。 在非阻塞模式下,調用 fgets() 總是會立即返回;而在阻塞模式下,將會一直等到從資源流里面獲取到數據才能返回。

返回值

成功時返回 true, 或者在失敗時返回 false。

注釋

注意:

在 Windows 系統上,這對本地文件沒有影響。Windows 不支持本地文件的非阻塞 IO。

參見

  • stream_select() - Runs the equivalent of the select() system call on the given arrays of streams with a timeout specified by seconds and microseconds