2014-06-14 17:02:50 +00:00
|
|
|
#include "qtsslsocket.h"
|
|
|
|
|
|
|
|
qtsslsocket::qtsslsocket(std::string server,int port) : flag(false)
|
|
|
|
{
|
|
|
|
socket = new QSslSocket();
|
|
|
|
socket->connectToHostEncrypted(server.c_str(), port);
|
|
|
|
if (socket->waitForEncrypted())
|
|
|
|
flag = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool qtsslsocket::isCon()
|
|
|
|
{
|
|
|
|
return flag;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool qtsslsocket::send(std::string str)
|
|
|
|
{
|
2014-06-18 18:42:46 +00:00
|
|
|
bool flag = isCon();
|
|
|
|
if (flag)
|
|
|
|
this->socket->write(str.c_str());
|
2014-06-14 17:02:50 +00:00
|
|
|
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool qtsslsocket::recieve(std::string &str)
|
|
|
|
{
|
|
|
|
bool flag = false;
|
|
|
|
QString s = "";
|
|
|
|
while (socket->waitForReadyRead(milisTimeOut))
|
|
|
|
s.append((socket->readAll().data()));
|
|
|
|
str = s.toStdString();
|
|
|
|
if (s.size() > 0)
|
|
|
|
flag = true;
|
|
|
|
return flag;
|
|
|
|
}
|