Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. any Windows networking mavens out there?
Forum Update on Monday, May 27th 2025

any Windows networking mavens out there?

Scheduled Pinned Locked Moved Solved Brainstorm
windowssocketsbroadcast
20 Posts 4 Posters 3.2k 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.
  • K kshegunov
    25 Apr 2020, 17:10

    @mzimmers said in any Windows networking mavens out there?:

    Bad choice of words on my part. The sockets are created and bound at app start-up, and never destroyed.

    Fair enough.

    I'm not connecting the dots -- where in that thread is there reference to the possibility of jinky LAN hardware?

    Not strictly hardware, but at the end where the suspect is an ARP cache refresh for which the OS's waiting and supposedly discards the pending datagrams instead of flushing them through the network. Now I don't know if that's at all connected to your case, but my point was you could try a simplified case to test if it may be ...

    Another thing that comes to mind, do you capture the errors signal?

    M Offline
    M Offline
    mzimmers
    wrote on 25 Apr 2020, 17:17 last edited by
    #9

    Another thing that comes to mind, do you capture the errors signal?

    Yes...no hits. And I check the return value of the send() in the debugger; all looks good. The app definitely thinks it's sending those broadcasts.

    Regarding the other thread, if I understand, that poster is (at the end) sending one message, then going into a short delay, then sending a ton of stuff all at once. He's attributing the delay to what's causing his program to work properly.

    But in my instance, I'm only sending one message every 3 seconds (or far less frequently when using the debugger), and I never see any output in Wireshark. So I'm still not sure what the takeaway is.

    K 1 Reply Last reply 25 Apr 2020, 17:49
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 25 Apr 2020, 17:45 last edited by
      #10

      Hi,

      Did you try to inspect your network activity with a tool like wireshark ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply 25 Apr 2020, 20:25
      0
      • M mzimmers
        25 Apr 2020, 17:17

        Another thing that comes to mind, do you capture the errors signal?

        Yes...no hits. And I check the return value of the send() in the debugger; all looks good. The app definitely thinks it's sending those broadcasts.

        Regarding the other thread, if I understand, that poster is (at the end) sending one message, then going into a short delay, then sending a ton of stuff all at once. He's attributing the delay to what's causing his program to work properly.

        But in my instance, I'm only sending one message every 3 seconds (or far less frequently when using the debugger), and I never see any output in Wireshark. So I'm still not sure what the takeaway is.

        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 25 Apr 2020, 17:49 last edited by
        #11

        @mzimmers said in any Windows networking mavens out there?:

        But in my instance, I'm only sending one message every 3 seconds (or far less frequently when using the debugger), and I never see any output in Wireshark. So I'm still not sure what the takeaway is.

        Something else you could try is to drop the shared flag and the multicast at least for time being and try an ordinary p2p datagram. Other than that nothing else comes to mind.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MEMekaniske
          wrote on 25 Apr 2020, 17:52 last edited by
          #12

          Hey!

          You are adding all known addresses to m_socks but I do not see you add it to your packets/sender anywhere?
          Also I cannot find any declaration for the addr m_addrBroadcast?

          M 1 Reply Last reply 25 Apr 2020, 20:42
          3
          • M Offline
            M Offline
            MEMekaniske
            wrote on 25 Apr 2020, 17:55 last edited by
            #13

            qha = addr->ip(); only declares one ip? when what you might need to do is iterate over the socket list?

            1 Reply Last reply
            1
            • S SGaist
              25 Apr 2020, 17:45

              Hi,

              Did you try to inspect your network activity with a tool like wireshark ?

              M Offline
              M Offline
              mzimmers
              wrote on 25 Apr 2020, 20:25 last edited by
              #14

              @SGaist yes, all of us did. That's the basis for my reported results.

              1 Reply Last reply
              0
              • M MEMekaniske
                25 Apr 2020, 17:52

                Hey!

                You are adding all known addresses to m_socks but I do not see you add it to your packets/sender anywhere?
                Also I cannot find any declaration for the addr m_addrBroadcast?

                M Offline
                M Offline
                mzimmers
                wrote on 25 Apr 2020, 20:42 last edited by
                #15

                @MEMekaniske said in any Windows networking mavens out there?:

                Hey!

                You are adding all known addresses to m_socks but I do not see you add it to your packets/sender anywhere?

                Ladies and gentlemen, we have a winner!

                I didn't realize I had to do that. The corrected code is:

                for (it = m_socks.begin(); it != m_socks.end(); ++it)
                {
                	m_datagramOut.setData(msg);
                	m_datagramOut.setSender(it->addr.ip());
                	m_datagramOut.setDestination(m_addrBroadcast, VOIP_BROADCAST_PORT);
                	rc = it->sockBroadcast->writeDatagram(m_datagramOut);
                

                and it works! (at least on my system)

                I can't even hazard a guess as to why the app worked without this added line on some systems.

                But...thanks a ton, MEMekaniske.

                M 1 Reply Last reply 26 Apr 2020, 05:49
                2
                • M mzimmers
                  25 Apr 2020, 20:42

                  @MEMekaniske said in any Windows networking mavens out there?:

                  Hey!

                  You are adding all known addresses to m_socks but I do not see you add it to your packets/sender anywhere?

                  Ladies and gentlemen, we have a winner!

                  I didn't realize I had to do that. The corrected code is:

                  for (it = m_socks.begin(); it != m_socks.end(); ++it)
                  {
                  	m_datagramOut.setData(msg);
                  	m_datagramOut.setSender(it->addr.ip());
                  	m_datagramOut.setDestination(m_addrBroadcast, VOIP_BROADCAST_PORT);
                  	rc = it->sockBroadcast->writeDatagram(m_datagramOut);
                  

                  and it works! (at least on my system)

                  I can't even hazard a guess as to why the app worked without this added line on some systems.

                  But...thanks a ton, MEMekaniske.

                  M Offline
                  M Offline
                  MEMekaniske
                  wrote on 26 Apr 2020, 05:49 last edited by
                  #16

                  @mzimmers

                  Hey, glad it sends out to everyone now :)
                  As I could not see the m_addrBroadcast declaration anywhere it's hard to say why it was not using the broadcast addr.

                  Anyways, if this works fine, no need to use more time on it I guess :)

                  M 1 Reply Last reply 26 Apr 2020, 13:08
                  1
                  • M MEMekaniske
                    26 Apr 2020, 05:49

                    @mzimmers

                    Hey, glad it sends out to everyone now :)
                    As I could not see the m_addrBroadcast declaration anywhere it's hard to say why it was not using the broadcast addr.

                    Anyways, if this works fine, no need to use more time on it I guess :)

                    M Offline
                    M Offline
                    mzimmers
                    wrote on 26 Apr 2020, 13:08 last edited by
                    #17

                    @MEMekaniske yes indeed. Here's the assignment you asked about:

                        m_addrBroadcast.setAddress(QHostAddress::Broadcast);
                    

                    This is done in the c'tor of the class.

                    Thanks again.

                    M 1 Reply Last reply 27 Apr 2020, 06:35
                    0
                    • M mzimmers
                      26 Apr 2020, 13:08

                      @MEMekaniske yes indeed. Here's the assignment you asked about:

                          m_addrBroadcast.setAddress(QHostAddress::Broadcast);
                      

                      This is done in the c'tor of the class.

                      Thanks again.

                      M Offline
                      M Offline
                      MEMekaniske
                      wrote on 27 Apr 2020, 06:35 last edited by
                      #18

                      @mzimmers

                      Hey, following that call I get the wrong broadcast addr for my network.
                      Cannot seem to get Qt to deliver the broadcast addr at all, it just returns the netmask with the last bits flipped and not the gateway

                      When calculating the broadcast addr myself then I get the correct one and it works fine.
                      Maybe you should set up a script yourself to calculate the broadcast addr for the system and let qt do other things :p

                      M 1 Reply Last reply 27 Apr 2020, 12:41
                      0
                      • M MEMekaniske
                        27 Apr 2020, 06:35

                        @mzimmers

                        Hey, following that call I get the wrong broadcast addr for my network.
                        Cannot seem to get Qt to deliver the broadcast addr at all, it just returns the netmask with the last bits flipped and not the gateway

                        When calculating the broadcast addr myself then I get the correct one and it works fine.
                        Maybe you should set up a script yourself to calculate the broadcast addr for the system and let qt do other things :p

                        M Offline
                        M Offline
                        mzimmers
                        wrote on 27 Apr 2020, 12:41 last edited by
                        #19

                        @MEMekaniske that's strange -- my datagrams are all fine, and according to Wireshark have all the correct addresses. What OS are you running?

                        M 1 Reply Last reply 27 Apr 2020, 15:49
                        0
                        • M mzimmers
                          27 Apr 2020, 12:41

                          @MEMekaniske that's strange -- my datagrams are all fine, and according to Wireshark have all the correct addresses. What OS are you running?

                          M Offline
                          M Offline
                          MEMekaniske
                          wrote on 27 Apr 2020, 15:49 last edited by
                          #20

                          @mzimmers If i iterate over the interfaces like in your script, then it works with no problem :)
                          Running on windows :)

                          When using only the QHostAddress::Broadcast I get the wrong broadcast addr. I too think it is strange, but this is no issue for me, as it's always simple to determine the right address by code or manually :) just strange as you say :)

                          Anways, off to new issues :D

                          1 Reply Last reply
                          0

                          18/20

                          27 Apr 2020, 06:35

                          • Login

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