Skip to content

Commit 649f6ff

Browse files
committed
Diagnosis: discuss changes to isConnected()
1 parent 06a490b commit 649f6ff

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

docs/diagnosis.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ SSH2.php doesn't connect to a server after the constructor has been called - it
5454

5555
Calling `isConnected()` prior to any of these methods will return `bool(false)`. Premature closure of the session will also result in `isConnected()` returning `bool(false)`.
5656

57+
As of phpseclib 3.0.36 `isConnected()` optionally takes a `$level` parameter that can be used to select the method used to test if the connection is still opened or not. The various levels are:
58+
59+
- `isConnected(0)`. The default method. Calls `feof()` on the socket object, which often means that the [server has closed the connection](https://stackoverflow.com/a/1321716/569976)
60+
- `isConnected(1)`. Sends a SSH_MSG_IGNORE packet to the server.
61+
- `isConnected(2)`. Sends a SSH_MSG_CHANNEL_OPEN packet to the server and then immediately closes the channel. Unlike `isConnected(1)` this method actually results in the server sending a response, however, some servers may limit the number of open channels that you can have, most notably, Cisco IOS Routers, which limit you to just one channel per session.
62+
5763
`isAuthenticated()` returns `bool(true)` only after you've been successfully logged in.
5864

5965
## getErrors(), getLastError()

0 commit comments

Comments
 (0)