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. facing problem in binding
Forum Updated to NodeBB v4.3 + New Features

facing problem in binding

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 2 Posters 1.4k 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.
  • jsulmJ jsulm

    @ManiRon Why don't you use http://doc.qt.io/qt-5/qtnetwork-index.html ? Then your question would be related to Qt.
    And you don't even mention what problem you face...

    ManiRonM Offline
    ManiRonM Offline
    ManiRon
    wrote on last edited by
    #3

    @jsulm my problem is when i try to bind data it returns an error saying the bind failed: invalid argument

    jsulmJ 1 Reply Last reply
    0
    • ManiRonM ManiRon

      @jsulm my problem is when i try to bind data it returns an error saying the bind failed: invalid argument

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @ManiRon Are you aware that your question is completely unrelated to Qt?
      You're using low level socket API not Qt.
      Please post at least the whole compiler error.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      ManiRonM 1 Reply Last reply
      0
      • jsulmJ jsulm

        @ManiRon Are you aware that your question is completely unrelated to Qt?
        You're using low level socket API not Qt.
        Please post at least the whole compiler error.

        ManiRonM Offline
        ManiRonM Offline
        ManiRon
        wrote on last edited by
        #5

        @jsulm yes sir this is what the error say invalid argument in bind

        jsulmJ 1 Reply Last reply
        0
        • ManiRonM ManiRon

          @jsulm yes sir this is what the error say invalid argument in bind

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @ManiRon Please copy paste the compiler error

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          ManiRonM 1 Reply Last reply
          0
          • jsulmJ jsulm

            @ManiRon Please copy paste the compiler error

            ManiRonM Offline
            ManiRonM Offline
            ManiRon
            wrote on last edited by
            #7

            @jsulm 0_1549519170378_Untitled.jpg

            jsulmJ 1 Reply Last reply
            0
            • ManiRonM ManiRon

              @jsulm 0_1549519170378_Untitled.jpg

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #8

              @ManiRon So, it's not a compiler error but a runtime error.
              You should zero your address first like

              bzero((char *) &address, sizeof(address));
              

              As shown here http://www.cs.rpi.edu/~moorthy/Courses/os98/Pgms/socket.html

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              ManiRonM 1 Reply Last reply
              2
              • jsulmJ jsulm

                @ManiRon So, it's not a compiler error but a runtime error.
                You should zero your address first like

                bzero((char *) &address, sizeof(address));
                

                As shown here http://www.cs.rpi.edu/~moorthy/Courses/os98/Pgms/socket.html

                ManiRonM Offline
                ManiRonM Offline
                ManiRon
                wrote on last edited by
                #9

                @jsulm said in facing problem in binding:

                bzero((char *) &address, sizeof(address));

                I used memset(&address, 0, sizeof(sockaddr_in)); this and set it to zero but still the problem exists

                jsulmJ 1 Reply Last reply
                0
                • ManiRonM ManiRon

                  @jsulm said in facing problem in binding:

                  bzero((char *) &address, sizeof(address));

                  I used memset(&address, 0, sizeof(sockaddr_in)); this and set it to zero but still the problem exists

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  @ManiRon Are you sure you want to use SOCK_DGRAM (UDP) and not SOCK_STREAM (TCP)?
                  If I remember correctly you don't need bind() for UDP.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  ManiRonM 2 Replies Last reply
                  0
                  • jsulmJ jsulm

                    @ManiRon Are you sure you want to use SOCK_DGRAM (UDP) and not SOCK_STREAM (TCP)?
                    If I remember correctly you don't need bind() for UDP.

                    ManiRonM Offline
                    ManiRonM Offline
                    ManiRon
                    wrote on last edited by
                    #11

                    @jsulm

                    I have to check

                    1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @ManiRon Are you sure you want to use SOCK_DGRAM (UDP) and not SOCK_STREAM (TCP)?
                      If I remember correctly you don't need bind() for UDP.

                      ManiRonM Offline
                      ManiRonM Offline
                      ManiRon
                      wrote on last edited by
                      #12

                      @jsulm

                      actually socket creation itself is a problem
                      server_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)

                      here server_fd is -1

                      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