socket_set_block

(PHP 4 >= 4.2.0, PHP 5)

socket_set_block -- Sets blocking mode on a socket resource

Description

bool socket_set_block ( resource socket )

The socket_set_block() function removes the O_NONBLOCK flag on the socket specified by the socket parameter.

Parameters

socket

Return Values

Returns TRUE on success or FALSE on failure.

Examples

Example 1. socket_set_block() 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) { // $socket is now nonblocking
    
echo "socket_set_nonblock() failed. Reason: ".socket_strerror(socket_last_error($socket));
}

if (
socket_set_block($socket) === false) {     // $socket is now blocking
    
echo "socket_set_block() failed. Reason: ". socket_strerror(socket_last_error($socket));
}

?>

See Also

socket_set_nonblock()
socket_set_option()