【问题标题】:How to listen on already connected QTcpSocket如何监听已经连接的 QTcpSocket
【发布时间】:2014-02-11 07:56:23
【问题描述】:

在客户端,我有连接到 QTcpServer 的套接字。我想在客户端创建一个 QtcpServer,它在同一个套接字上侦听。我试过了。

QTcpSocket *tcpSocket=new QTcpSocket(this); //connected socket.
QTcpServer *tcpServer=new QTcpServer(this);
tcpSocket->bind(QAbstractSocket::ReuseAddressHint);
tcpServer->setSocketDescriptor(tcpSocket->socketDescriptor());

tcpServer 正在侦听同一个套接字,但其他客户端无法连接到该 tcpServer; 显示套接字操作超时消息。 建议的解决方案是什么。

【问题讨论】:

    标签: qt


    【解决方案1】:

    QTcpSocket 继承 QIODevice 所以连接到信号 readyRead()
    请记住this topic

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-02-18
    • 2012-07-24
    • 1970-01-01
    • 2012-08-12
    • 1970-01-01
    • 1970-01-01
    • 2019-03-13
    相关资源
    最近更新 更多