Forum PHP 2026 - Paris (France)

ssh2_set_timeout

(PECL ssh2 >= 1.5.0)

ssh2_set_timeoutSet the timeout for blocking operations on a session

Описание

function ssh2_set_timeout(resource $session, int $seconds, int $microseconds = 0): void

Sets how long a blocking operation on the given session may wait before it is considered to have timed out.

When the resulting timeout is 0, which is the default, no timeout is applied and blocking operations may wait indefinitely.

Список параметров

session

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

seconds

The timeout, in seconds.

microseconds

An additional number of microseconds added to the timeout. The underlying library only supports millisecond precision, so this value is rounded up to the next whole millisecond.

Возвращаемые значения

Функция не возвращает значения после выполнения.

Примеры

Пример #1 Limiting how long blocking operations may wait

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

// Give up on blocking operations after 5.5 seconds
ssh2_set_timeout($connection, 5, 500000);

ssh2_auth_password($connection, 'username', 'password');
?>

Смотрите также

  • ssh2_connect() - Подключается к серверу по протоколу SSH
  • ssh2_keepalive_config() - Configure how often keepalive messages should be sent
  • stream_set_timeout() - Устанавливает значение времени ожидания для потока
Добавить

Примечания пользователей

Пользователи ещё не добавляли примечания для страницы
To Top