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. how can i know that my LAN is working or not
Qt 6.11 is out! See what's new in the release blog

how can i know that my LAN is working or not

Scheduled Pinned Locked Moved Solved General and Desktop
38 Posts 5 Posters 12.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.
  • V victor wang

    @jsulm
    It got some error when i during compiling.
    It is my code here

    It is the error here

    I just type the same thing up to my code.

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

    @victor-wang Even better is http://doc.qt.io/qt-5/qiodevice.html#errorString

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

    V 1 Reply Last reply
    0
    • jsulmJ jsulm

      @victor-wang Even better is http://doc.qt.io/qt-5/qiodevice.html#errorString

      V Offline
      V Offline
      victor wang
      wrote on last edited by victor wang
      #19

      @jsulm
      You mean change like this?
      If not where i should add this on?

      I had tried it. and will show the error
      "QAbstractSocket::SocketTimeoutError"

      And if i use

      qDebug <<socket->errorString();
      

      It will show this error "Socket operation timed out"

      jsulmJ 1 Reply Last reply
      0
      • V victor wang

        @jsulm
        You mean change like this?
        If not where i should add this on?

        I had tried it. and will show the error
        "QAbstractSocket::SocketTimeoutError"

        And if i use

        qDebug <<socket->errorString();
        

        It will show this error "Socket operation timed out"

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

        @victor-wang Yes, like this. Even better is http://doc.qt.io/qt-5/qiodevice.html#errorString

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

        V 1 Reply Last reply
        0
        • jsulmJ jsulm

          @victor-wang Yes, like this. Even better is http://doc.qt.io/qt-5/qiodevice.html#errorString

          V Offline
          V Offline
          victor wang
          wrote on last edited by victor wang
          #21

          @jsulm
          I'm using port 8888.

          I had tried it. and will show the error
          "QAbstractSocket::SocketTimeoutError"

          And i if i use

          qDebug<<socket->errorString();
          

          It will show this error "Socket operation timed out"

          So is that mean i had set the time too long?

          jsulmJ 1 Reply Last reply
          0
          • the_T the_

            @victor-wang
            would be easier if you paste your code here and not on external sites as pictures ;)

            V Offline
            V Offline
            victor wang
            wrote on last edited by
            #22

            @the_
            My code is too long.
            I'm using qtcreator via Xming.
            So i can't copy my code, i just can type it.
            And because of there are too many codes i have no time to type it.
            That's why i using as picture.

            1 Reply Last reply
            0
            • V victor wang

              @jsulm
              I'm using port 8888.

              I had tried it. and will show the error
              "QAbstractSocket::SocketTimeoutError"

              And i if i use

              qDebug<<socket->errorString();
              

              It will show this error "Socket operation timed out"

              So is that mean i had set the time too long?

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

              @victor-wang said in how can i know that my LAN is working or not:

              So is that mean i had set the time too long?

              No, it means that it was not possible to connect in that time.
              You're doing it wrong. Please read documentation (http://doc.qt.io/qt-5/qabstractsocket.html#connectToHost): hostName is a URL not IP.
              If you want to use IP then use http://doc.qt.io/qt-5/qabstractsocket.html#connectToHost-1

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

              V 1 Reply Last reply
              0
              • jsulmJ jsulm

                @victor-wang said in how can i know that my LAN is working or not:

                So is that mean i had set the time too long?

                No, it means that it was not possible to connect in that time.
                You're doing it wrong. Please read documentation (http://doc.qt.io/qt-5/qabstractsocket.html#connectToHost): hostName is a URL not IP.
                If you want to use IP then use http://doc.qt.io/qt-5/qabstractsocket.html#connectToHost-1

                V Offline
                V Offline
                victor wang
                wrote on last edited by
                #24

                @jsulm
                Ok, i see.
                Now i tried to connect to the IP 192.168.120.115 like here

                And i print the error out shows "Connection refused"
                Is that because this IP address need the password to enter it?

                If it is, what should i do to solve this problem?

                jsulmJ 1 Reply Last reply
                0
                • V victor wang

                  @jsulm
                  Ok, i see.
                  Now i tried to connect to the IP 192.168.120.115 like here

                  And i print the error out shows "Connection refused"
                  Is that because this IP address need the password to enter it?

                  If it is, what should i do to solve this problem?

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

                  @victor-wang You're still doing it wrong. Please read documentation - I posted the links.
                  If you want to use IP address you need to pass http://doc.qt.io/qt-5/qhostaddress.html as parameter not a string.

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

                  V 1 Reply Last reply
                  1
                  • jsulmJ jsulm

                    @victor-wang You're still doing it wrong. Please read documentation - I posted the links.
                    If you want to use IP address you need to pass http://doc.qt.io/qt-5/qhostaddress.html as parameter not a string.

                    V Offline
                    V Offline
                    victor wang
                    wrote on last edited by
                    #26

                    @jsulm
                    Is that mean i have to set address first like this?

                    hostaddress->setAddress(192.168.120.115);
                    

                    Then connect it like this?

                    socket->connectToHost(hostaddress,PT_lanHostPort);
                    

                    Is that right?

                    jsulmJ 1 Reply Last reply
                    0
                    • V victor wang

                      @jsulm
                      Is that mean i have to set address first like this?

                      hostaddress->setAddress(192.168.120.115);
                      

                      Then connect it like this?

                      socket->connectToHost(hostaddress,PT_lanHostPort);
                      

                      Is that right?

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

                      @victor-wang Yes

                      socket->connectToHost(QHostAddress("192.168.120.115"), PT_lanHostPort);
                      

                      Why do you allocate everything on the heap with new? hostaddress can be just a local variable:

                      QHostAddress hostaddress("192.168.120.115");
                      socket.connectToHost(hostaddress, PT_lanHostPort); // No need to allocate socket on the heap with new as well!
                      

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

                      V 1 Reply Last reply
                      1
                      • jsulmJ jsulm

                        @victor-wang Yes

                        socket->connectToHost(QHostAddress("192.168.120.115"), PT_lanHostPort);
                        

                        Why do you allocate everything on the heap with new? hostaddress can be just a local variable:

                        QHostAddress hostaddress("192.168.120.115");
                        socket.connectToHost(hostaddress, PT_lanHostPort); // No need to allocate socket on the heap with new as well!
                        
                        V Offline
                        V Offline
                        victor wang
                        wrote on last edited by victor wang
                        #28

                        @jsulm
                        Sorry, i'm new in Qt.Please be patient to me :)
                        This is my code here

                        It still print "connection refused".

                        Why will it refused to connect?

                        "192.168.120.115" this is an IP which is a server and i need password and user to login.
                        Is this a factor that cause the error?

                        jsulmJ 1 Reply Last reply
                        0
                        • V victor wang

                          @jsulm
                          Sorry, i'm new in Qt.Please be patient to me :)
                          This is my code here

                          It still print "connection refused".

                          Why will it refused to connect?

                          "192.168.120.115" this is an IP which is a server and i need password and user to login.
                          Is this a factor that cause the error?

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

                          @victor-wang It is not a Qt thing, it is C++.
                          It should actually work even if authentication is required. Is port number correct? Can you ping this IP?

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

                          V 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @victor-wang It is not a Qt thing, it is C++.
                            It should actually work even if authentication is required. Is port number correct? Can you ping this IP?

                            V Offline
                            V Offline
                            victor wang
                            wrote on last edited by
                            #30

                            @jsulm
                            I'm sure that i can ping this IP address!
                            But i don't know how to check the port number.

                            jsulmJ the_T 2 Replies Last reply
                            0
                            • V victor wang

                              @jsulm
                              I'm sure that i can ping this IP address!
                              But i don't know how to check the port number.

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

                              @victor-wang Well, you should know on which port your server is listening.

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

                              V 1 Reply Last reply
                              0
                              • V victor wang

                                @jsulm
                                I'm sure that i can ping this IP address!
                                But i don't know how to check the port number.

                                the_T Offline
                                the_T Offline
                                the_
                                wrote on last edited by
                                #32

                                @victor-wang

                                A socket connection to the server is always possible, even if you need a username and a password to authenticate for using its service.
                                In case you do not provide any login data or incorrect login data the server is still responding to your request.

                                • What kind of service is running on this host?
                                • How do you usually connect to this host?

                                -- No support in PM --

                                1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @victor-wang Well, you should know on which port your server is listening.

                                  V Offline
                                  V Offline
                                  victor wang
                                  wrote on last edited by
                                  #33

                                  @jsulm

                                  Is there any way that i can know the port it is listening?

                                  @the_
                                  It is linux on it.
                                  i will connect it through PUTTY.

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • V victor wang

                                    @jsulm

                                    Is there any way that i can know the port it is listening?

                                    @the_
                                    It is linux on it.
                                    i will connect it through PUTTY.

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

                                    @victor-wang Check your server configuration. How, depends on what server it is (Apache, NGNX,...). Or ask the people who manage the server.

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

                                    V 1 Reply Last reply
                                    0
                                    • jsulmJ jsulm

                                      @victor-wang Check your server configuration. How, depends on what server it is (Apache, NGNX,...). Or ask the people who manage the server.

                                      V Offline
                                      V Offline
                                      victor wang
                                      wrote on last edited by
                                      #35

                                      @jsulm
                                      I've change the port and it success!
                                      Thank you so much !
                                      I think i need to practice more.

                                      jsulmJ 1 Reply Last reply
                                      1
                                      • V victor wang

                                        @jsulm
                                        I've change the port and it success!
                                        Thank you so much !
                                        I think i need to practice more.

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

                                        @victor-wang Good!
                                        And don't forget to read documentation :-)

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

                                        Julian GuarinJ 1 Reply Last reply
                                        4
                                        • jsulmJ jsulm

                                          @victor-wang Good!
                                          And don't forget to read documentation :-)

                                          Julian GuarinJ Offline
                                          Julian GuarinJ Offline
                                          Julian Guarin
                                          wrote on last edited by
                                          #37

                                          @jsulm You are a patience ninja and a Gentleman. Great to see still people like you in these forums!!!

                                          jsulmJ 1 Reply Last reply
                                          2

                                          • Login

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