91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 18KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-05-12
  • 語言: 其他
  • 標(biāo)簽: QT??TCP??

資源簡介

多線程通信,QT5.11.1,多線程TCP服務(wù)器,多線程連接客戶端。QThread

資源截圖

代碼片段和文件信息

#include?“DispatcherThread.h“
#include
#include
DispatcherThread::DispatcherThread(Qobject?*parent):
????QThread(parent)
{

?????this->moveToThread(this);
}

DispatcherThread::~DispatcherThread()
{
????delete?m_tcpSocket;
}

void?DispatcherThread::setSocketDescriptor(qintptr?sockFd)
{

????socketDescriptor?=?sockFd;
}

void?DispatcherThread::readData()
{

????qDebug()<
????//讀取緩沖區(qū)數(shù)據(jù)
????QByteArray?buffer?=?m_tcpSocket->readAll();
????QString?msg?=?buffer;
????qDebug()<<“>>>>receive?stringData:“<????emit?updateMsg(?m_tcpSocket->peerAddress().toString()+?“_“?+?QString::number(m_tcpSocket->peerPort())msg);

????QJsonobject?jsonobject?=?QJsonDocument::fromJson(buffer).object();
????jsonobject.insert(“socketDescriptor“socketDescriptor);
????emit?updateMsg(jsonobject);
????qDebug()<<“>>>>receive?jsonData:“<ject;
????return;
}

void?DispatcherThread::slotDisconnected()
{
????qDebug()<????qDebug()<>>>disconnect?to:?%1“).arg(m_tcpSocket->peerAddress().toString());
????exit(0);
????emit?closeMe(this);
}

void?DispatcherThread::writeData(int?sptr?QJsonobject?json)
{
????if(sptr?==?socketDescriptor)
????{
????????qDebug()<<“###########“<????????QByteArray?byte_array?=?QJsonDocument(json).toJson();
?????????byte_array.append(“$$\n“);
????????m_tcpSocket->write(byte_array);
????????qDebug()<????}
}

void?DispatcherThread::run()
{
????qDebug()<????m_tcpSocket?=?new?QTcpSocket;
????m_tcpSocket->setSocketDescriptor((qintptr)socketDescriptor);
????connect(m_tcpSocketSIGNAL(readyRead())thisSLOT(readData()));
????connect(m_tcpSocketSIGNAL(disconnected())thisSLOT(slotDisconnected()));
????setAddressIp(m_tcpSocket->peerAddress().toString());
????emit?updateClient(addressIp);
????this->exec();
}

QString?DispatcherThread::getAddressIp()?const
{
????return?addressIp;
}

void?DispatcherThread::setAddressIp(const?QString?&value)
{
????addressIp?=?value;
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????515??2018-12-02?18:04??SeverProject\configure.ini

?????文件???????2155??2018-12-05?19:41??SeverProject\DispatcherThread.cpp

?????文件????????866??2018-12-05?15:31??SeverProject\DispatcherThread.h

?????文件???????4703??2018-12-02?17:51??SeverProject\IMSGlobal.cpp

?????文件???????2328??2018-12-02?16:21??SeverProject\IMSGlobal.h

?????文件????????185??2017-10-23?13:56??SeverProject\main.cpp

????I.A....?????17904??2018-12-05?19:41??SeverProject\PlcClient.cpp

????I.A....??????1469??2018-12-05?16:30??SeverProject\PlcClient.h

????I.A....??????3002??2018-12-05?15:17??SeverProject\Robotbase.cpp

????I.A....???????651??2018-12-05?15:13??SeverProject\Robotbase.h

?????文件???????4067??2018-12-05?19:41??SeverProject\RobotThread.cpp

?????文件????????965??2018-12-05?19:30??SeverProject\RobotThread.h

????I.A....??????2327??2018-12-05?18:50??SeverProject\server.cpp

????I.A....??????1001??2018-12-05?17:02??SeverProject\server.h

????I.A....??????1296??2018-12-05?19:30??SeverProject\SeverProject.pro

?????文件??????23921??2018-12-05?17:48??SeverProject\SeverProject.pro.user

????I.A....??????4084??2018-12-05?19:37??SeverProject\severwindow.cpp

????I.A....???????887??2018-12-05?19:30??SeverProject\severwindow.h

?????文件???????6427??2018-12-02?20:22??SeverProject\severwindow.ui

?????目錄??????????0??2018-12-05?19:44??SeverProject

-----------?---------??----------?-----??----

????????????????78753????????????????????20


評論

共有 條評論