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. QTcpSocket and error
QtWS25 Last Chance

QTcpSocket and error

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 3.1k 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.
  • F Offline
    F Offline
    Franckynos
    wrote on 19 May 2017, 14:11 last edited by
    #1

    I have a problem in my application, i think it's a problem with "arp" table or set ip address.

    I have 2 applications "Server" and "Client"

    The application "Server" before launching QTcpServer configure and Ad-hoc network and the static ip of Server => 192.168.0.10.
    The application "Client" before launching QTcpSocket configure the connexion with the ad-hoc network and its static ip is => 192.168.0.20.

    I run this application under 2 PC one app for each.
    PC A => run "Server"
    PC B => run "Client"

    First case the connection works:
    If i run A and after B, the connection is established.
    if i run B and after A, the connection is established.

    The communication work, so I close both applications.

    Second case, i switch applications
    I run PC A => "Client"
    and PC B => "Server"

    My server say the connection is established at 192.168.0.10.
    If i make "ipconfig" on PC B i have 192.168.0.10

    But my client on PC A cannot join the server, the QAbstractSocketError say 'QAbstractSocket::ConnectionRefusedError' if I make "ipconfig" on PC A I have 192.168.0.20

    I have a good response of "ping 192.168.0.10" from "Client"
    I have a good response of "ping 192.168.0.20" from "Server"

    And if i tried on PC A the "Client" to connec with telnet (open 192.168.0.10 port) it doesn't work.??? Why?

    If I change the ip address of "Server" to 192.168.0.11, it will working.
    In "192.168.0.10" it's seems to be occupied or something like that.
    Someone can help me ?

    Thx

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on 19 May 2017, 15:48 last edited by
      #2

      Hi! Are your firewalls shut down? MAC (SELinux, AppArmor, Tomoyo) disabled?

      1 Reply Last reply
      2
      • F Offline
        F Offline
        Franckynos
        wrote on 20 May 2017, 13:42 last edited by Franckynos
        #3

        It's not a problème with firewall because it works in first case.
        If I have used ip 192.168.0.x in first case for the server it works.
        And if i swith the client and server on pc with the same address 192.168.0.x it doesn't work.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 20 May 2017, 14:09 last edited by
          #4

          Hi
          How do you assign these ips?

          If you are on a network with dhcp you can't use what ever
          ip you want for static.

          The correct way is to lower the range for automatically assigned ips on the dhcp router and
          then use one of none shared ips for static.
          Some routers can also do it based mac addresses.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Franckynos
            wrote on 21 May 2017, 10:24 last edited by
            #5

            Hi
            Thanks for your reply.

            There isn't dhcp because I have no router it's ad hoc network created under windows with cmd:

            Netsh wlan start hostednetwork.

            And I assign ip address with a command like that:
            Netsh interface ip set address name="Wi-Fi" static 192.168.0.10 255.255.255.0.

            M 1 Reply Last reply 21 May 2017, 10:37
            0
            • F Franckynos
              21 May 2017, 10:24

              Hi
              Thanks for your reply.

              There isn't dhcp because I have no router it's ad hoc network created under windows with cmd:

              Netsh wlan start hostednetwork.

              And I assign ip address with a command like that:
              Netsh interface ip set address name="Wi-Fi" static 192.168.0.10 255.255.255.0.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 21 May 2017, 10:37 last edited by
              #6

              @Franckynos

              Ok it sounds like you know networking pretty well then.
              So if its ad hoc, it seems unlikely that the ip be in use.
              I have no further ideas it it seems u done ping test etc.

              Give it some days and see if others have better ideas.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 21 May 2017, 20:57 last edited by
                #7

                Hi,

                What port are you using ? Do you have anything else that might use it ?

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

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  Franckynos
                  wrote on 22 May 2017, 06:46 last edited by
                  #8

                  The port used is 5555 but the comminucation works well.

                  PC A (Server) => 192.168.0.10
                  PC B (Client) => 192.168.0.20

                  OK

                  but if i swith server and client.
                  PC B (Server) => 192.168.0.10
                  PC A (Client) => 192.168.0.20

                  The connection can be established.

                  If i change the ip of server in this configuration
                  PC B (Server) => 192.168.0.11
                  PC A (Client) => 192.168.0.20

                  it'll work ? But i don't know why.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 22 May 2017, 19:59 last edited by
                    #9

                    Than a silly question, did you check that the port is not still opened ?

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

                    1 Reply Last reply
                    1
                    • F Offline
                      F Offline
                      Franckynos
                      wrote on 23 May 2017, 12:18 last edited by
                      #10

                      How can i do that ? with listening ?

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 23 May 2017, 19:38 last edited by
                        #11

                        netstat would likely be more appropriate

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

                        1 Reply Last reply
                        0

                        1/11

                        19 May 2017, 14:11

                        • Login

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