socket_set_nonblock

(PHP 4 >= 4.1.0, PHP 5)

socket_set_nonblock -- Sets nonblocking mode for file descriptor fd

Description

bool socket_set_nonblock ( resource socket )

The socket_set_nonblock() function sets the O_NONBLOCK flag on the socket specified by the socket parameter.

Example 1. socket_set_nonblock() example

<?php
$port
= 9090;
if ((
$socket = socket_create_listen($port)) === false) {
    echo
"socket_create_listen() failed. Reason: ".socket_strerror(socket_last_error());
}

if (
socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1) === false) {
    echo
"socket_set_option() failed. Reason: ".socket_strerror(socket_last_error($socket));
}

if (
socket_set_nonblock($socket) === false) {
    echo
"socket_set_nonblock() failed. Reason: ".socket_strerror(socket_last_error($socket));
}
?>

Returns TRUE on success or FALSE on failure.

See also socket_set_block() and socket_set_option()


Follow phpf1 on Twitter




F1 Site Family
AJAX F1
CSS F1
Database F1
Flash F1
HTML F1
Java F1
JavaScript F1
PhotoShop F1
PHP F1
Scripts F1
Tutorial F1
Windows F1

Total time: 0.0471