Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. QTcpSocket报错
Forum Updated to NodeBB v4.3 + New Features

QTcpSocket报错

Scheduled Pinned Locked Moved Unsolved Chinese
1 Posts 1 Posters 800 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    coderKnight
    wrote on last edited by
    #1

    我有一个设备有两个网卡,我想使用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
    这两条错误,卡了好几天了

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved