Forum PHP 2026 - Paris (France)

ssh2_keepalive_config

(PECL ssh2 >= 1.5.0)

ssh2_keepalive_configConfigure how often keepalive messages should be sent

Açıklama

function ssh2_keepalive_config(resource $session, bool $want_reply, int $interval): void

Configures how often keepalive messages are sent on the given session, and whether the server is asked to reply to them.

Keepalive messages are not sent automatically. Once configured, ssh2_keepalive_send() must be called to actually send a keepalive message.

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().

want_reply

Whether the server is requested to reply to keepalive messages. Requesting a reply makes an unresponsive server detectable, at the cost of some extra traffic.

interval

The number of seconds that may pass without any traffic before a keepalive message should be sent. A value of 0 disables keepalive messages, and a value of 1 is treated as 2 by the underlying library.

Accepted values range from 0 to 4294967295.

Dönen Değerler

Hiçbir değer dönmez.

Hatalar/İstisnalar

An E_WARNING is emitted when interval is outside the accepted range, in which case the keepalive configuration is left unchanged.

Örnekler

Örnek 1 Sending keepalive messages

<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');

// Ask the server to reply, after 30 seconds without any traffic
ssh2_keepalive_config($connection, true, 30);

// Keepalive messages are only sent when this function is called
ssh2_keepalive_send($connection);
?>

Ayrıca Bakınız

add a note

User Contributed Notes

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