English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and Examples of PHP socket set blocking() Function

PHP HTTP Reference Manual

The PHP socket set blocking() function sets blocking or blocking mode for resource streams

Syntax

bool stream_set_blocking ( resource $stream , int $mode )

Definition and Usage

It is an alias for STREAM_SET_BLOCKING(), which has blocking or unblocking options for stream mode.

Return Value

Returns true on success, otherwise returns false

Parameter

Serial NumberParameters and Description
1

stream

resource stream

2

mode

If mode is 0, the resource stream will be converted to non-blocking mode; if it is1, the resource stream will be converted to blocking mode.

The setting of this parameter will affect functions like fgets() and fread() that read data from the resource stream.

In non-blocking mode, calling fgets() will always return immediately; while in blocking mode, it will wait until data is obtained from the resource stream before returning.

PHP HTTP Reference Manual