Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Force QTcpSocket traffic over specific network interface

Force QTcpSocket traffic over specific network interface

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.9k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    drwho
    wrote on last edited by
    #1

    In the same PC, I have a wired and wireless network device (in Kubuntu 13.04), eth0 and wlan0, both with different IPs on the same subnet. I have a QTcpServer on each of them on different ports. The listen on wlan0 uses wlan0's IP (eg 192.168.13.193) and the listen on eth0 uses eth0's IP (eg 192.168.13.102).

    @QNetworkInterface wlan0 = QNetworkInterface::interfaceFromName("wlan0");
    tcpServer = new QTcpServer(this);
    tcpServer->listen(wlan0.addressEntries().first().ip(), 12346);
    connect(tcpServer, SIGNAL(newConnection()), this, SLOT(link()));@

    ..link() slot
    @tcp_client = tcpServer->nextPendingConnection();@

    From another linux machine on the same subnet, I make two client connections

    socat tcp:192.168.13.102:12345 -
    socat tcp:192.168.13.193:12346 -

    after which I do a tcp_client->write(a bunch of data); ...using the tcp_client associated to the wlan0 interface. The problem is that the data goes over eth0 instead of wlan0. I need to test that the wlan0 interface is working correctly. I suspect this isn't possible to control from the application and I may need to change my routing at the OS level. Can anyone confirm?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      You can't control this application level. It is the way routing, arp requests happen at TCP/IP level. You try disabling eth0 interface and work just with WLAN0 interface.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • D Offline
        D Offline
        drwho
        wrote on last edited by
        #3

        Thanks for the confirmation. I need to keep eth0 up for the tester command & control. I guess its off to the dreaded iptables.

        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