(PECL ssh2 >= 1.5.0)
ssh2_keepalive_send — Send a keepalive message
Sends a keepalive message on the given session,
according to the configuration set with
ssh2_keepalive_config().
Nota:
This function is only available when the extension is built against a libssh2 version providing keepalive support.
sessionAn SSH connection link identifier, obtained from a call to ssh2_connect().
Returns the number of seconds that may pass before another keepalive message
must be sent, or false on failure. 0 is returned when
keepalive messages are disabled.
Since 0 and false are both falsy, the
=== operator has to be used to tell them apart.
Exemplo #1 Sending a keepalive message
<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
ssh2_keepalive_config($connection, true, 30);
$seconds = ssh2_keepalive_send($connection);
if ($seconds === false) {
echo "The keepalive message could not be sent", PHP_EOL;
} elseif ($seconds === 0) {
echo "Keepalive messages are disabled", PHP_EOL;
} else {
echo "Next keepalive message due in $seconds seconds", PHP_EOL;
}
?>