Saturday, 15 February 2014

sockets - how to write datagram through a specific network interface in QT? -


I am using Qt 4.8 on Linux.

I want to write UDP datagram and send it to me. From specific network interfaces.

I have 2 interfaces:

  1. WLan: IP 192.168.1.77 and MAC address
  2. Eth: IP 192.168.1.80 < / Div>

    post-text "itemprop =" text ">

    The short answer is.

    Qt is very strange to me, but when I need to get dirty, I will use something like that.

    Still, you start There is something to do, but you should look at QtCreator or more solid examples:

      QUdpSocket SOCK I have been using ET interface which is associated with IP 19.168.1.77 / // Note that I am using a "random" (instantaneous) port if passing through 0 (socket .bind (QHostAddress ("192.168.1.77"), 0)) {// send it to some IP (192.168.1.1) and port (45354). Qint64 bytescent = socket.Litatagram (QByteArray ("Hello World!"), QHostAdde ("192.168.1.1"), 45354); // ... etc ...}    

No comments:

Post a Comment