SO_KEEPALIVE for php

 

SO_KEEPALIVE for php stream sockets

socket_set_option
(PHP 4 >= 4.3.0, PHP 5)
bool socket_set_option ( resource $socket , int $level , int $optname , mixed $optval )

# You need to socket_import_stream first:

$stream = stream_socket_client('tcp://127.0.0.1:5672');
$sock = socket_import_stream($stream);
socket_set_option($sock, SOL_SOCKET, SO_KEEPALIVE, 1);

 

 

Creative Commons license icon Creative Commons license icon