QTcpSocket报错



  • 我有一个设备有两个网卡,我想使用QTcpSocket指定网卡收发数据,我调用了bind函数,但是不起作用,好像发送数据的时候并没有通过指定的网卡,而是根据路由表选择发送网卡,为了实现这个,我在外部创建了一个原始socket,通过setsockopt(tcpSocketFd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr));实现绑定网卡,然后用QTcpSocket下的setSocketDescriptor函数设置socket句柄,但是时不时的就回报QNativeSocketEngine::read() was called not in QAbstractSocket::ConnectedState or QAbstractSocket::BoundState
    QNativeSocketEngine::bytesAvailable() was called in QAbstractSocket::UnconnectedState
    这两条错误,卡了好几天了


Log in to reply