socket_set_nonblock
PHP Manual
PHP Manual»Socket Funzioni»socket_set_nonblock

socket_set_nonblock

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

socket_set_nonblockAttiva la modalità "nonblocking" per il descrittore di file fd

Descrizione

function socket_set_nonblock(resource $socket): bool
Avviso

Questa funzione è SPERIMENTALE. Ovvero, il comportamento di questa funzione, il nome di questa funzione, in definitiva tutto ciò che è documentato qui può cambiare nei futuri rilasci del PHP senza preavviso. Siete avvisati, l'uso di questa funzione è a vostro rischio.

La funzione socket_set_nonblock() imposta il flag O_NONBLOCK per il socket indicato dal parametro socket.

Example #1 Esempio di uso di socket_set_nonblock()

<?php 
$port = 9090; 
if (!$socket = socket_create_listen($port)) { 
    echo socket_strerror(socket_last_error()); 
} 
 
if (!socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1)) { 
    echo socket_strerror(socket_last_error()); 
} 
 
if (!socket_set_nonblock($socket)) { 
    echo socket_strerror(socket_last_error()); 
} 
?>

Restituisce true in caso di successo, false in caso di fallimento.

Vedere anche socket_set_block() e socket_set_option()

To Top