当前位置: 首页 > news >正文

企业标准信息公共服务平台官网seo还有未来吗

企业标准信息公共服务平台官网,seo还有未来吗,做任务赚q币网站,公司注册网上核名几个字到官网下载qssh的源码QSsh-botan-1,使用qtcreator打开后,直接编译,即可得到qssh的库 头文件将QSsh-botan-1\src\libs\ssh目录下的.h文件拷到include文件夹下,即为库头文件。 qssh有个问题,如果你将qssh的类放在子线程…

到官网下载qssh的源码QSsh-botan-1,使用qtcreator打开后,直接编译,即可得到qssh的库

 头文件将QSsh-botan-1\src\libs\ssh目录下的.h文件拷到include文件夹下,即为库头文件。

qssh有个问题,如果你将qssh的类放在子线程中调用,将获取不到服务器发送回来的数据。故只能放在主线程调用。如有需要从子线程调用的话,可通过在子线程发送信号来调用主线程的槽,从而调用到qssh的功能,使得qssh在主线程调用,即能正常使用。

封装如下:

// .h
#ifndef SSHCLIENT_H
#define SSHCLIENT_H
#include <qobject.h>
#include "sshconnection.h"
#include "sshremoteprocess.h"class SshClient : public QObject
{Q_OBJECT
public:SshClient();~SshClient();void ConnectToHost(const QString &host, const QString &user, const QString &pwd);void DisConnectFromHost();void SendCmd(const QByteArray &data);signals:void SendDataRecv(const QByteArray &data);void SendConnected(bool bConned);void SendShellStarted(bool bStarted);void SendRetMsg(const QString &msg);private slots:void OnConnected();void onConnectionError(QSsh::SshError);void OnShellStarted();void OnShellDataRecieved();void OnShellError();private:QString mIp;QString mUserName;QString mPwd;QSsh::SshConnection *mpConnection = Q_NULLPTR; // 连接ssh服务器QSharedPointer<QSsh::SshRemoteProcess> mpShell; // ssh的shell用于发送与回显消息
};#endif // SSHCLIENT_H// .cpp
#include <qcoreapplication.h>
#include "sshclient.h"
#include "log.h"SshClient::SshClient()
{}SshClient::~SshClient()
{DisConnectFromHost();
}void SshClient::ConnectToHost(const QString &host, const QString &username, const QString &pwd)
{QSsh::SshConnectionParameters params;params.setHost(host);params.setUserName(username);params.setPassword(pwd);params.authenticationType = QSsh::SshConnectionParameters::AuthenticationTypePassword;params.timeout = 10;//30;params.setPort(22);if(mpConnection == Q_NULLPTR){mpConnection = new QSsh::SshConnection(params, this); // TODO free this pointer!}connect(mpConnection, SIGNAL(connected()), SLOT(OnConnected()));connect(mpConnection, SIGNAL(error(QSsh::SshError)), SLOT(onConnectionError(QSsh::SshError)));mpConnection->disconnectFromHost();mpConnection->connectToHost();LOG_INFO("conneting to host:%s user:%s pwd:%s",qPrintable(host),qPrintable(username),qPrintable(pwd));
}void SshClient::DisConnectFromHost()
{if(mpShell){emit SendShellStarted(false);mpShell->close();mpShell.reset();}if(mpConnection != Q_NULLPTR){emit SendConnected(false);mpConnection->disconnectFromHost();delete mpConnection;mpConnection = Q_NULLPTR;}
}void SshClient::OnConnected()
{emit SendConnected(true);LOG_INFO("ssh is connected");mpShell = mpConnection->createRemoteShell();connect(mpShell.get(), SIGNAL(started()), SLOT(OnShellStarted()));connect(mpShell.get(), SIGNAL(readyReadStandardOutput()), SLOT(OnShellDataRecieved()));connect(mpShell.get(), SIGNAL(readyReadStandardError()), SLOT(OnShellError()));mpShell->start();
}void SshClient::onConnectionError(QSsh::SshError)
{QString errStr = mpConnection->errorString();emit SendRetMsg(QString::fromLocal8Bit("连接出错:%1").arg(errStr));LOG_ERROR("ssh connected err:%s",mpConnection->errorString().toLocal8Bit().data());//mpConnection->disconnectFromHost();// mpConnection->connectToHost();
}void SshClient::OnShellStarted()
{LOG_INFO("shell is started");SendShellStarted(true);
}void SshClient::OnShellDataRecieved()
{QByteArray data = mpShell->readAll();if (data.isEmpty())return;emit SendDataRecv(data);LOG_DEBUG("recv from shell data:%s",data.data());
}void SshClient::OnShellError()
{emit SendRetMsg(QString::fromLocal8Bit("错误:%1").arg(mpShell->errorString()));LOG_ERROR("recv from shell err:%s",mpShell->errorString().toLocal8Bit().data());
}// 发送了命令后,shell会回复两条同样的命令,用于回显
void SshClient::SendCmd(const QByteArray &data)
{if(!mpShell){LOG_ERROR("shell is not start, can't sendmsg:%s",data.data());return;}qint64 n = mpShell->write(data);LOG_DEBUG("write shell data, len:%d, data:%s",n,data.data());static const int timeoutMs = 3000;int index = 0;bool bsucc = mpShell->waitForReadyRead(10);while(!bsucc && index < timeoutMs){	index += 10;QCoreApplication::processEvents();if (!mpShell) break;bsucc = mpShell->waitForReadyRead(10);} /*if (bsucc){QByteArray data = mpShell->readAll();if (data.isEmpty())return;emit SendDataRecv(data);LOG_DEBUG("recv from shell data:%s", data.data());}*/
}

http://www.hengruixuexiao.com/news/28773.html

相关文章:

  • 智慧团建手机登录入口电脑版pc端seo网站推广软件 快排
  • 大连大型网站制作公司学技术包分配的培训机构
  • 刚学完网站开发企业软文营销发布平台
  • 国内产品设计网站推广一单500
  • linux怎么做网站湖南网站营销seo多少费用
  • wordpress最新列表南京seo优化
  • wordpress文章目录独立站seo外链平台
  • 企业管理培训课程表seo自学
  • 城乡建设部网站第35号令宁德市安全教育平台
  • 公司独立网站平台建设浏览器网址
  • 门户网站建设情况汇报淘宝关键词
  • qq群网站制作职业培训学校加盟
  • 网站广告下悬浮代码怎么做seo外包大型公司
  • 网站手机模板和pc模板要分开做软文写作方法
  • 建设网站费用吗网页推广方案
  • 荣耀手机商城官方网站下载公司企业网站开发
  • php网站开发流程谷歌推广方案
  • 国药控股北京有限公司seo导航站
  • wordpress模板 古典seo技术是什么意思
  • 学习前端开发的网站百度图片搜索引擎入口
  • 重庆网站排名提升全球最牛的搜索引擎
  • 北京市密云县建设委员会网站百度小说搜索风云榜总榜
  • 大连制作网站报价灰色seo关键词排名
  • 网站设置会员成品网站seo
  • 东莞最新新闻廊坊seo排名公司
  • 网站建设属于广告费吗seo培训
  • 在做好政府网站建设方面企业seo案例
  • 上海知名网站温州百度推广公司电话
  • 网站建设交易十大技能培训机构排名
  • 买个网站空间品牌策略怎么写