ssh client now reuses an existing session instead of opening a new one

This commit is contained in:
vladimir.kuznetsov 2024-04-12 20:00:21 +05:00
parent 624a84cbfb
commit ec650a65f7
32 changed files with 395 additions and 451 deletions

View file

@ -23,6 +23,13 @@ namespace libssh {
ErrorCode Client::connectToHost(const ServerCredentials &credentials)
{
if (m_session != nullptr) {
if (!ssh_is_connected(m_session)) {
ssh_free(m_session);
m_session = nullptr;
}
}
if (m_session == nullptr) {
m_session = ssh_new();