QTcpSocket readyRead信号问题求救!
一个c/s程序,目的是通过客户端的键盘鼠标动作,控制服务端的电脑.但是在readyRead槽函数中发现了问题:
当我在客户端连续快速按下按钮时,服务端的readyRead槽函数的QTcpSocket->read()就开始出错了.如:当我快速按下 AABBCC 6个按键.服务端最后只收到了AAB.当我继续缓慢按下DDE 3个按键这时服务端则接受到了BCC...
根据这种情况我觉的应该是readyRead信号发送那边出了问题,但是socket底层是正确收到封包的.
各位大神帮忙分析下是什么导致这样的情况呢?.
客户端发送代码片段:
void MainWindow::on_pB_A_clicked()
{
this->m_senPath.nType = Controller::Key;
this->m_senPath.nKeyType = Controller::Key_A;
this->m_senPath.nKeyAction = Controller::KeyClick;
this->m_pTapSocket->write((char *)&this->m_senPath, sizeof(NetworkPath));
}
服务端接收代码片段:
void MainWindow::onTcpSocket_ReadyRead()
{
this->m_pTcpSocket->read((char *)&this->m_Action, sizeof(NetworkPath));
// 响应事件
switch(this->m_Action.nType){
case Controller::Key:{
// 按键事件
this->m_Contorller.KeyAction(this->m_Action);
}break;
case Controller::Mouse:{
// 鼠标事件
this->m_Contorller.MouseAction(this->m_Action);
}break;
default:{
}break;
}
} qt QTcpSocket readyRead
补充:移动开发 , Qt