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. [Workaround]Strange udp socket when interchanging messages between Linux and Windows Box

[Workaround]Strange udp socket when interchanging messages between Linux and Windows Box

Scheduled Pinned Locked Moved General and Desktop
network socketudpwindowslinux
11 Posts 2 Posters 4.5k 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi
    +1 for good problem description.

    That is really strange.

    (stupid question)
    And its not just Linux \n, Windows \r\n. line endings so it
    never considered fully read when mixing OSes. ?

    And both Qt on win/linux is same version so its not something there?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vman
      wrote on last edited by
      #3

      Both QT versions are 5.5.
      \n and \r\n is not used, only \t to have a field separator. BTW: the application that sends the broadcast message only send "AutodetectRequest" without any line ending characters. And this mesage is received by application B.
      Nevertheless I tried your suggestion and add \n and \r\n to the answer, but this does not change anything.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vman
        wrote on last edited by
        #4

        Maybe it has something to do with the binding? On both systems I use
        socket->bind(40102);
        I also tried
        socket->bind(QHostAddress::Any, 40102);
        and
        socket->bind(QHostAddress::AnyIPv4, 40102);

        but this doesn't solve the problem as well.

        mrjjM 1 Reply Last reply
        0
        • V vman

          Maybe it has something to do with the binding? On both systems I use
          socket->bind(40102);
          I also tried
          socket->bind(QHostAddress::Any, 40102);
          and
          socket->bind(QHostAddress::AnyIPv4, 40102);

          but this doesn't solve the problem as well.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #5

          @vman
          Hmm.
          And since you already have used WireShark, im kinda out of ideas for now.

          It cannot be linux firewall as that would also block linux <->linux, I assume.

          maybe try something like netcat
          https://eternallybored.org/misc/netcat/

          to see if other apps can do cross udp ?

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vman
            wrote on last edited by
            #6

            Hi mrjj,

            I'm now sure it has something to do with the broadcast message. I modified application B a little bit and add a push button that sends exactly the same message that is sent as answer to the broadcast. And, surprisingly, this message is received by application A.

            Just to make clear what happens.

            I bind the udp socket on app A this way:

            socket->bind(40102);
            If I send messages from the Linux box to the Windows Box, these messages are received.

            Then I send a broadcast message from app A to app B using
            socket->writeDatagram(buffer, QHostAddress::Broadcast, 40102);
            From now on, neither the answer message from app B nor the message that was sent by push button from app B is received any more.
            So it seems that sending the broadcast message blocks the port for receiving.

            mrjjM 1 Reply Last reply
            0
            • V vman

              Hi mrjj,

              I'm now sure it has something to do with the broadcast message. I modified application B a little bit and add a push button that sends exactly the same message that is sent as answer to the broadcast. And, surprisingly, this message is received by application A.

              Just to make clear what happens.

              I bind the udp socket on app A this way:

              socket->bind(40102);
              If I send messages from the Linux box to the Windows Box, these messages are received.

              Then I send a broadcast message from app A to app B using
              socket->writeDatagram(buffer, QHostAddress::Broadcast, 40102);
              From now on, neither the answer message from app B nor the message that was sent by push button from app B is received any more.
              So it seems that sending the broadcast message blocks the port for receiving.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #7

              @vman said:

              sending the broadcast message blocks the port for receiving

              But why would it do that ?
              Sorry I couldn't be more helpful.

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vman
                wrote on last edited by
                #8

                Well, to be precise, sending the broadcast message seems to prevent the socket from receiving messages from the Linux box. If the second app runs on windows then everything works as expected. So I'm still not 100% sure that the problem is in App A (the broadcasting app). It could be on app B as well.

                mrjjM 1 Reply Last reply
                0
                • V vman

                  Well, to be precise, sending the broadcast message seems to prevent the socket from receiving messages from the Linux box. If the second app runs on windows then everything works as expected. So I'm still not 100% sure that the problem is in App A (the broadcasting app). It could be on app B as well.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  @vman
                  and we 100% rule out both build-in firewalls ?

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    vman
                    wrote on last edited by vman
                    #10

                    and we 100% rule out both build-in firewalls ?

                    I think yes, otherwise I would not see the udp messages in wireshark.

                    AND

                    if I replace
                    socket->writeDatagram(buffer, QHostAddress::Broadcast, 40102);
                    with

                    QHostAddress ip;
                    ip.setAddress("192.168.1.7") // The IP of the box running App B
                    socket->writeDatagram(buffer, ip, 40102);
                    

                    then it works correct. But as soon as I send a broadcast message app A can not receive any packages (again, only the the answer comes from a Linux box, the problem disappears if both are windows or both are linux)

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      vman
                      wrote on last edited by
                      #11

                      OK, I use two sockets now.
                      On App A I have one socket for sending the broadcast message, and a second one on another port for receiving the answer.
                      Same on App B. One socket for receiving the broadcast message and a second one for sending the answer on a different port.

                      Still would be very happy if someone can find a solution for this using only one udp socket.

                      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