Qt socket测试

 

if (tcpSocketObj->state()==QAbstractSocket::SocketState::ConnectedState)
{
    qDebug() << "send  data:"<<dataStr;
    tcpSocketObj->write(dataStr.toUtf8());
}

 

if (tcpSocketObj->state() == QAbstractSocket::ConnectedState) 
{
    QByteArray data = tcpSocketObj->readAll();
    qDebug() << "Received data:" << data;
    // 在这里处理接收到的数据
}

 

 

 

######################

posted @ 2024-08-17 22:49  西北逍遥  阅读(7)  评论(0编辑  收藏  举报