Forum PHP 2026 - Paris (France)

ssh2_keepalive_send

(PECL ssh2 >= 1.5.0)

ssh2_keepalive_sendSend a keepalive message

Açıklama

function ssh2_keepalive_send(resource $session): int|false

Sends a keepalive message on the given session, according to the configuration set with ssh2_keepalive_config().

Bilginize:

This function is only available when the extension is built against a libssh2 version providing keepalive support.

Bağımsız Değişkenler

session

An SSH connection link identifier, obtained from a call to ssh2_connect().

Dönen Değerler

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.

Örnekler

Örnek 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;
}
?>

Ayrıca Bakınız

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top