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. Failed to bind UDP socket
Forum Updated to NodeBB v4.3 + New Features

Failed to bind UDP socket

Scheduled Pinned Locked Moved Unsolved General and Desktop
20 Posts 4 Posters 5.0k Views 2 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.
  • KroMignonK KroMignon

    @SPlatten said in Failed to bind UDP socket:

    Failed to bind UDP socket: The address is not available

    Maybe a silly question, but are you sure IP 169.254.50.150 is available testing system?

    EDIT: you can check it easily with this:

        foreach(const QHostAddress &laddr, QNetworkInterface::allAddresses())
        {
            qDebug() << "Found IP:" << laddr.toString();
        }
     
    
    SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #5

    @KroMignon This is my code:

        for( const QHostAddress& address : QNetworkInterface::allAddresses() )
        {
            if ( address.protocol() == QAbstractSocket::IPv4Protocol )
            {
                QString strAddress(address.toString());
                if ( !(strAddress.compare("localhost") == 0
                    || strAddress.compare("127.0.0.1") == 0) )
               {
                    return QHostAddress(address);//"10.186.53.82");
                }
            }
        }
        return QHostAddress();
    

    I intentionally don't want to use "localhost" or "127.0.0.1", so the IP returned is most definitely from a local adapter.

    Kind Regards,
    Sy

    KroMignonK 1 Reply Last reply
    0
    • SPlattenS SPlatten

      @KroMignon This is my code:

          for( const QHostAddress& address : QNetworkInterface::allAddresses() )
          {
              if ( address.protocol() == QAbstractSocket::IPv4Protocol )
              {
                  QString strAddress(address.toString());
                  if ( !(strAddress.compare("localhost") == 0
                      || strAddress.compare("127.0.0.1") == 0) )
                 {
                      return QHostAddress(address);//"10.186.53.82");
                  }
              }
          }
          return QHostAddress();
      

      I intentionally don't want to use "localhost" or "127.0.0.1", so the IP returned is most definitely from a local adapter.

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by KroMignon
      #6

      @SPlatten said in Failed to bind UDP socket:

      I intentionally don't want to use "localhost" or "127.0.0.1", so the IP returned is most definitely from a local adapter.

      Just as side note: you could check this with address.isLoopback().

      Can you show how the error message is generated?

      It is strange, because QNetworkInterface::allAddresses() should only returns IP addresses from network interfaces which are up/active.

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      SPlattenS 1 Reply Last reply
      1
      • KroMignonK KroMignon

        @SPlatten said in Failed to bind UDP socket:

        I intentionally don't want to use "localhost" or "127.0.0.1", so the IP returned is most definitely from a local adapter.

        Just as side note: you could check this with address.isLoopback().

        Can you show how the error message is generated?

        It is strange, because QNetworkInterface::allAddresses() should only returns IP addresses from network interfaces which are up/active.

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #7

        @KroMignon The only information I have is from a screenshot taken from the screen of the guy running the application which shows exactly what I posted initially:

        UDP on IP: 169.254.50.150 port: 30119
        Failed to bind UDP socket:  The address is not available
        

        Kind Regards,
        Sy

        KroMignonK 1 Reply Last reply
        0
        • SPlattenS SPlatten

          @KroMignon The only information I have is from a screenshot taken from the screen of the guy running the application which shows exactly what I posted initially:

          UDP on IP: 169.254.50.150 port: 30119
          Failed to bind UDP socket:  The address is not available
          
          KroMignonK Offline
          KroMignonK Offline
          KroMignon
          wrote on last edited by
          #8

          @SPlatten said in Failed to bind UDP socket:

          The only information I have is from a screenshot taken from the screen of the guy running the application which shows exactly what I posted initially:
          UDP on IP: 169.254.50.150 port: 30119
          Failed to bind UDP socket: The address is not available

          But this message has been generated with your application, or did I miss understood something?

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          SPlattenS 1 Reply Last reply
          0
          • KroMignonK KroMignon

            @SPlatten said in Failed to bind UDP socket:

            The only information I have is from a screenshot taken from the screen of the guy running the application which shows exactly what I posted initially:
            UDP on IP: 169.254.50.150 port: 30119
            Failed to bind UDP socket: The address is not available

            But this message has been generated with your application, or did I miss understood something?

            SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #9

            @KroMignon , only the first line comes from my application. I assume the second line is from a Qt object.

            Kind Regards,
            Sy

            JonBJ KroMignonK 2 Replies Last reply
            0
            • SPlattenS SPlatten

              @KroMignon , only the first line comes from my application. I assume the second line is from a Qt object.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #10

              @SPlatten
              I don't think this will be a Qt issue. Try Googling Failed to bind UDP socket: The address is not available, you get a few hits worth reading through?

              SPlattenS 1 Reply Last reply
              0
              • JonBJ JonB

                @SPlatten
                I don't think this will be a Qt issue. Try Googling Failed to bind UDP socket: The address is not available, you get a few hits worth reading through?

                SPlattenS Offline
                SPlattenS Offline
                SPlatten
                wrote on last edited by SPlatten
                #11

                @JonB , @KroMignon , sorry, I found the message, its displayed when:

                    const QHostAddress local(localAddress());   
                    //The server is also going to listen for UDP data
                    qinf() << QString("UDP on IP: %1 port: %2").arg(local.toString())
                                                               .arg(SckServer::msuint16PortUDP);
                    if ( !this->bind(local, SckServer::msuint16PortUDP, QUdpSocket::ShareAddress |
                                                                        QUdpSocket::ReuseAddressHint) )
                    {
                        qcrt() << SckServer::tr("Failed to bind UDP socket: ").toLatin1().data()
                               << this->errorString();
                        exit(EXIT_FAILURE);
                    }
                

                localAddress() contains the source I posted earlier, now with the modification:

                QHostAddress SckServer::localAddress()
                {
                    for( const QHostAddress& address : QNetworkInterface::allAddresses() )
                    {
                        if ( address.protocol() == QAbstractSocket::IPv4Protocol &&
                             address.isLoopback() != true )
                        {
                            return address;
                        }
                    }
                    return QHostAddress();
                }
                

                Kind Regards,
                Sy

                1 Reply Last reply
                0
                • SPlattenS SPlatten

                  @KroMignon , only the first line comes from my application. I assume the second line is from a Qt object.

                  KroMignonK Offline
                  KroMignonK Offline
                  KroMignon
                  wrote on last edited by
                  #12

                  @SPlatten said in Failed to bind UDP socket:

                  I assume the second line is from a Qt object.

                  This error message is when trying to use an local IP address which is not available.
                  For me, it looks like your system has IP configuration issues.
                  Do your system have multiple network interfaces?
                  Is this IP configured on several interfaces?

                  It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                  SPlattenS 1 Reply Last reply
                  0
                  • KroMignonK KroMignon

                    @SPlatten said in Failed to bind UDP socket:

                    I assume the second line is from a Qt object.

                    This error message is when trying to use an local IP address which is not available.
                    For me, it looks like your system has IP configuration issues.
                    Do your system have multiple network interfaces?
                    Is this IP configured on several interfaces?

                    SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by
                    #13

                    @KroMignon , my system has no issues, its another system which a colleague is trying to run the application on. I think its down to configuration, but I cannot determine why because I don't have access to the system.

                    Kind Regards,
                    Sy

                    KroMignonK 1 Reply Last reply
                    0
                    • SPlattenS SPlatten

                      @KroMignon , my system has no issues, its another system which a colleague is trying to run the application on. I think its down to configuration, but I cannot determine why because I don't have access to the system.

                      KroMignonK Offline
                      KroMignonK Offline
                      KroMignon
                      wrote on last edited by
                      #14

                      @SPlatten said in Failed to bind UDP socket:

                      my system has no issues, its another system which a colleague is trying to run the application on. I think its down to configuration, but I cannot determine why because I don't have access to the system.

                      "Your system" == "the not working system"

                      I had understood that it was not on development machine ;)

                      Perhaps your colleague could send you the output of: ipconfig /all > ipconfig.txt (I assume it is a Window system)
                      So you could check the IP configuration of the machine.

                      This would be my way to understand/solve the issue.

                      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                      SPlattenS 1 Reply Last reply
                      0
                      • KroMignonK KroMignon

                        @SPlatten said in Failed to bind UDP socket:

                        my system has no issues, its another system which a colleague is trying to run the application on. I think its down to configuration, but I cannot determine why because I don't have access to the system.

                        "Your system" == "the not working system"

                        I had understood that it was not on development machine ;)

                        Perhaps your colleague could send you the output of: ipconfig /all > ipconfig.txt (I assume it is a Window system)
                        So you could check the IP configuration of the machine.

                        This would be my way to understand/solve the issue.

                        SPlattenS Offline
                        SPlattenS Offline
                        SPlatten
                        wrote on last edited by
                        #15

                        @KroMignon , first line of my post:

                        "The application works fine on the development system, however I have sent to application to another for testing and the problem is when trying to execute the application"

                        The development machine is my system. And your instruction is exactly the content I sent to my colleague hours ago, the response came back with very little output. Windows 10. He is now waiting for IT to take a look at the computer.

                        Kind Regards,
                        Sy

                        KroMignonK 1 Reply Last reply
                        0
                        • SPlattenS SPlatten

                          @KroMignon , first line of my post:

                          "The application works fine on the development system, however I have sent to application to another for testing and the problem is when trying to execute the application"

                          The development machine is my system. And your instruction is exactly the content I sent to my colleague hours ago, the response came back with very little output. Windows 10. He is now waiting for IT to take a look at the computer.

                          KroMignonK Offline
                          KroMignonK Offline
                          KroMignon
                          wrote on last edited by
                          #16

                          @SPlatten said in Failed to bind UDP socket:

                          "The application works fine on the development system, however I have sent to application to another for testing and the problem is when trying to execute the application"

                          Yes, I have read this.

                          • I have understood that it works your PC.
                          • I have understood that is does not work on your colleague PC

                          What I say, is that, IMHO, the problem is linked to "not working PC" network configuration.
                          That's all what I say, but it is only a feeling. This is why showing the network configuration could be a key to understand what's going wrong.

                          It could also be a security issue, maybe the account used to start application have no right to use this interface.

                          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                          SPlattenS 1 Reply Last reply
                          1
                          • KroMignonK KroMignon

                            @SPlatten said in Failed to bind UDP socket:

                            "The application works fine on the development system, however I have sent to application to another for testing and the problem is when trying to execute the application"

                            Yes, I have read this.

                            • I have understood that it works your PC.
                            • I have understood that is does not work on your colleague PC

                            What I say, is that, IMHO, the problem is linked to "not working PC" network configuration.
                            That's all what I say, but it is only a feeling. This is why showing the network configuration could be a key to understand what's going wrong.

                            It could also be a security issue, maybe the account used to start application have no right to use this interface.

                            SPlattenS Offline
                            SPlattenS Offline
                            SPlatten
                            wrote on last edited by
                            #17

                            @KroMignon Thank you, waiting to hear back from colleague.

                            Kind Regards,
                            Sy

                            1 Reply Last reply
                            0
                            • SPlattenS SPlatten

                              The application I am working on uses UDP to communicate with other processes. The application works fine on the development system, however I have sent to application to another for testing and the problem is when trying to execute the application:

                              UDP on IP: 169.254.50.150 port: 30119
                              Failed to bind UDP socket:  The address is not available
                              

                              The first message is generated by my application and reported as status information. I'm not sure why or the cause of the next message, can anyone help?

                              Pablo J. RoginaP Offline
                              Pablo J. RoginaP Offline
                              Pablo J. Rogina
                              wrote on last edited by
                              #18

                              @SPlatten said in Failed to bind UDP socket:

                              UDP on IP: 169.254.50.150

                              It looks like the NIC in that machine couldn't get an IP assigned from the DHCP server. See this post for more details.

                              Upvote the answer(s) that helped you solve the issue
                              Use "Topic Tools" button to mark your post as Solved
                              Add screenshots via postimage.org
                              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                              KroMignonK SPlattenS 2 Replies Last reply
                              6
                              • Pablo J. RoginaP Pablo J. Rogina

                                @SPlatten said in Failed to bind UDP socket:

                                UDP on IP: 169.254.50.150

                                It looks like the NIC in that machine couldn't get an IP assigned from the DHCP server. See this post for more details.

                                KroMignonK Offline
                                KroMignonK Offline
                                KroMignon
                                wrote on last edited by
                                #19

                                @Pablo-J-Rogina said in Failed to bind UDP socket:

                                It looks like the NIC in that machine couldn't get an IP assigned from the DHCP server.

                                Good catch!

                                It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                                1 Reply Last reply
                                0
                                • Pablo J. RoginaP Pablo J. Rogina

                                  @SPlatten said in Failed to bind UDP socket:

                                  UDP on IP: 169.254.50.150

                                  It looks like the NIC in that machine couldn't get an IP assigned from the DHCP server. See this post for more details.

                                  SPlattenS Offline
                                  SPlattenS Offline
                                  SPlatten
                                  wrote on last edited by
                                  #20

                                  @Pablo-J-Rogina thank you, will look into it.

                                  Kind Regards,
                                  Sy

                                  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