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 connecting even tho no server?
QtWS25 Last Chance

QTcpSocket connecting even tho no server?

Scheduled Pinned Locked Moved Unsolved General and Desktop
28 Posts 7 Posters 3.8k 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.
  • S Offline
    S Offline
    SPlatten
    wrote on 21 Dec 2020, 10:16 last edited by
    #1

    In my application I am using QTcpSocket to connect to another process. The other process would be on the same system listening to a different port in this case 8124. This process isn't running.

    My main application tries to connect to this process using:

    mpsckClient->connectToHost(strIP, muint16Port);
    

    Where strIP is my local system IP address and muint16Port is 8124. I would expect this to fail because nothing is running listening to that port. However after the call the isOpen function returns true which indicates it is connected, why is this the case?

    This is my onStartupSlot:

    void clsMsgSender::onStartService() {
    qdbg() << mpsckClient->isOpen();
        if ( mpsckClient->isOpen() != true ) {
        //Change connection interval to regular connection time period for reconnects
            mptmrConnect->setInterval(clsMsgSender::mscuint16ConnectTimer);
        //Get local IP address
            QString strIP = clsMsgSender::strGetLocalIP();
            qdbg() << "Connecting to: " << strIP << ":" << muint16Port;
        //Connect to the Application
            mpsckClient->connectToHost(strIP, muint16Port);
        }
        if ( clsMsgSender::mspThread == nullptr ) {
            clsMsgSender::mspThread = new QThread;
            moveToThread(clsMsgSender::mspThread);
            QObject::connect(clsMsgSender::mspThread, &QThread::started
                        ,this, &clsMsgSender::run);
            QObject::connect(this, &clsMsgSender::finished
                        ,clsMsgSender::mspThread, &QThread::quit);
        }
        if ( mqueMsgsOut.size() > 0 && clsMsgSender::mspThread != nullptr ) {
            clsMsgSender::mspThread->start();
        }
    }
    

    I can see that isOpen is false on the first call, then true after the connectToHost.

    Kind Regards,
    Sy

    J 1 Reply Last reply 21 Dec 2020, 10:28
    0
    • S SPlatten
      21 Dec 2020, 10:16

      In my application I am using QTcpSocket to connect to another process. The other process would be on the same system listening to a different port in this case 8124. This process isn't running.

      My main application tries to connect to this process using:

      mpsckClient->connectToHost(strIP, muint16Port);
      

      Where strIP is my local system IP address and muint16Port is 8124. I would expect this to fail because nothing is running listening to that port. However after the call the isOpen function returns true which indicates it is connected, why is this the case?

      This is my onStartupSlot:

      void clsMsgSender::onStartService() {
      qdbg() << mpsckClient->isOpen();
          if ( mpsckClient->isOpen() != true ) {
          //Change connection interval to regular connection time period for reconnects
              mptmrConnect->setInterval(clsMsgSender::mscuint16ConnectTimer);
          //Get local IP address
              QString strIP = clsMsgSender::strGetLocalIP();
              qdbg() << "Connecting to: " << strIP << ":" << muint16Port;
          //Connect to the Application
              mpsckClient->connectToHost(strIP, muint16Port);
          }
          if ( clsMsgSender::mspThread == nullptr ) {
              clsMsgSender::mspThread = new QThread;
              moveToThread(clsMsgSender::mspThread);
              QObject::connect(clsMsgSender::mspThread, &QThread::started
                          ,this, &clsMsgSender::run);
              QObject::connect(this, &clsMsgSender::finished
                          ,clsMsgSender::mspThread, &QThread::quit);
          }
          if ( mqueMsgsOut.size() > 0 && clsMsgSender::mspThread != nullptr ) {
              clsMsgSender::mspThread->start();
          }
      }
      

      I can see that isOpen is false on the first call, then true after the connectToHost.

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 21 Dec 2020, 10:28 last edited by J.Hilk
      #2

      @SPlatten isOpen() is from the very base QIODevice class, I'm not sure when exactly this is set.

      What you should be looking for in your QTcpSocket instance, is state() and wether or not that is QAbstractSocket::ConnectedState


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      S 1 Reply Last reply 21 Dec 2020, 10:36
      3
      • J J.Hilk
        21 Dec 2020, 10:28

        @SPlatten isOpen() is from the very base QIODevice class, I'm not sure when exactly this is set.

        What you should be looking for in your QTcpSocket instance, is state() and wether or not that is QAbstractSocket::ConnectedState

        S Offline
        S Offline
        SPlatten
        wrote on 21 Dec 2020, 10:36 last edited by
        #3

        @J-Hilk , thank you, I've changed the code to:

        void clsMsgSender::onStartService() {
        qdbg() << mpsckClient->state();
            if ( mpsckClient->state() != QAbstractSocket::ConnectedState ) {
            //Change connection interval to regular connection time period for reconnects
                mptmrConnect->setInterval(clsMsgSender::mscuint16ConnectTimer);
            //Get local IP address
                QString strIP = clsMsgSender::strGetLocalIP();
                qdbg() << "Connecting to: " << strIP << ":" << muint16Port;
            //Connect to the Application
                mpsckClient->connectToHost(strIP, muint16Port);
            }
            if ( clsMsgSender::mspThread == nullptr ) {
                clsMsgSender::mspThread = new QThread;
                moveToThread(clsMsgSender::mspThread);
                QObject::connect(clsMsgSender::mspThread, &QThread::started
                            ,this, &clsMsgSender::run);
                QObject::connect(this, &clsMsgSender::finished
                            ,clsMsgSender::mspThread, &QThread::quit);
            }
            if ( mqueMsgsOut.size() > 0 && clsMsgSender::mspThread != nullptr ) {
                clsMsgSender::mspThread->start();
            }
        }
        

        I've also added a connection to:

        QObject::connect(mpsckClient, &QTcpSocket::hostFound
                            ,this, &clsMsgSender::onHostFound);
        

        In my onHostFound slot:

        void clsMsgSender::onHostFound() {
           qdbg() << "Host Found!";
        }
        

        From the Application Output I can see lots of Host Found! messages, is this normal when the IP:Port doesn't have anything listening to it?

        Kind Regards,
        Sy

        O K 2 Replies Last reply 21 Dec 2020, 10:39
        0
        • S SPlatten
          21 Dec 2020, 10:36

          @J-Hilk , thank you, I've changed the code to:

          void clsMsgSender::onStartService() {
          qdbg() << mpsckClient->state();
              if ( mpsckClient->state() != QAbstractSocket::ConnectedState ) {
              //Change connection interval to regular connection time period for reconnects
                  mptmrConnect->setInterval(clsMsgSender::mscuint16ConnectTimer);
              //Get local IP address
                  QString strIP = clsMsgSender::strGetLocalIP();
                  qdbg() << "Connecting to: " << strIP << ":" << muint16Port;
              //Connect to the Application
                  mpsckClient->connectToHost(strIP, muint16Port);
              }
              if ( clsMsgSender::mspThread == nullptr ) {
                  clsMsgSender::mspThread = new QThread;
                  moveToThread(clsMsgSender::mspThread);
                  QObject::connect(clsMsgSender::mspThread, &QThread::started
                              ,this, &clsMsgSender::run);
                  QObject::connect(this, &clsMsgSender::finished
                              ,clsMsgSender::mspThread, &QThread::quit);
              }
              if ( mqueMsgsOut.size() > 0 && clsMsgSender::mspThread != nullptr ) {
                  clsMsgSender::mspThread->start();
              }
          }
          

          I've also added a connection to:

          QObject::connect(mpsckClient, &QTcpSocket::hostFound
                              ,this, &clsMsgSender::onHostFound);
          

          In my onHostFound slot:

          void clsMsgSender::onHostFound() {
             qdbg() << "Host Found!";
          }
          

          From the Application Output I can see lots of Host Found! messages, is this normal when the IP:Port doesn't have anything listening to it?

          O Offline
          O Offline
          ollarch
          wrote on 21 Dec 2020, 10:39 last edited by
          #4

          @SPlatten said in QTcpSocket connecting even tho no server?:

          From the Application Output I can see lots of Host Found! messages, is this normal when the IP:Port doesn't have anything listening to it?

          But the host if found. The problem will be if the localhost is not found. One thing is that it found the host and the other thing is that there is some process linstening on the port.

          S 1 Reply Last reply 21 Dec 2020, 10:42
          2
          • O ollarch
            21 Dec 2020, 10:39

            @SPlatten said in QTcpSocket connecting even tho no server?:

            From the Application Output I can see lots of Host Found! messages, is this normal when the IP:Port doesn't have anything listening to it?

            But the host if found. The problem will be if the localhost is not found. One thing is that it found the host and the other thing is that there is some process linstening on the port.

            S Offline
            S Offline
            SPlatten
            wrote on 21 Dec 2020, 10:42 last edited by
            #5

            @ollarch , the IP exists on the system, but there is no application running listening for connection, nothing is using that port.

            Kind Regards,
            Sy

            J O 2 Replies Last reply 21 Dec 2020, 10:45
            0
            • S SPlatten
              21 Dec 2020, 10:36

              @J-Hilk , thank you, I've changed the code to:

              void clsMsgSender::onStartService() {
              qdbg() << mpsckClient->state();
                  if ( mpsckClient->state() != QAbstractSocket::ConnectedState ) {
                  //Change connection interval to regular connection time period for reconnects
                      mptmrConnect->setInterval(clsMsgSender::mscuint16ConnectTimer);
                  //Get local IP address
                      QString strIP = clsMsgSender::strGetLocalIP();
                      qdbg() << "Connecting to: " << strIP << ":" << muint16Port;
                  //Connect to the Application
                      mpsckClient->connectToHost(strIP, muint16Port);
                  }
                  if ( clsMsgSender::mspThread == nullptr ) {
                      clsMsgSender::mspThread = new QThread;
                      moveToThread(clsMsgSender::mspThread);
                      QObject::connect(clsMsgSender::mspThread, &QThread::started
                                  ,this, &clsMsgSender::run);
                      QObject::connect(this, &clsMsgSender::finished
                                  ,clsMsgSender::mspThread, &QThread::quit);
                  }
                  if ( mqueMsgsOut.size() > 0 && clsMsgSender::mspThread != nullptr ) {
                      clsMsgSender::mspThread->start();
                  }
              }
              

              I've also added a connection to:

              QObject::connect(mpsckClient, &QTcpSocket::hostFound
                                  ,this, &clsMsgSender::onHostFound);
              

              In my onHostFound slot:

              void clsMsgSender::onHostFound() {
                 qdbg() << "Host Found!";
              }
              

              From the Application Output I can see lots of Host Found! messages, is this normal when the IP:Port doesn't have anything listening to it?

              K Offline
              K Offline
              KroMignon
              wrote on 21 Dec 2020, 10:45 last edited by KroMignon
              #6

              @SPlatten said in QTcpSocket connecting even tho no server?:

              From the Application Output I can see lots of Host Found! messages, is this normal when the IP:Port doesn't have anything listening to it?

              Why do you never read documentation before asking what already describe in documentation?
              Have you tried to read connectToHost() documentation (hint: just hit F1 key in Qt Creator):

              Attempts to make a connection to hostName on the given port. The protocol parameter can be used to specify which network protocol to use (eg. IPv4 or IPv6).

              The socket is opened in the given openMode and first enters HostLookupState, then performs a host name lookup of hostName. If the lookup succeeds, hostFound() is emitted and QAbstractSocket enters ConnectingState. It then attempts to connect to the address or addresses returned by the lookup. Finally, if a connection is established, QAbstractSocket enters ConnectedState and emits connected().

              At any point, the socket can emit errorOccurred() to signal that an error occurred.

              hostName may be an IP address in string form (e.g., "43.195.83.32"), or it may be a host name (e.g., "example.com"). QAbstractSocket will do a lookup only if required. port is in native byte order.

              As you could read:

              • the socket is opened, so QTcpSocket::isOpen() will return true
              • hostname lookup is started ==> hostFound() is emitted on success
              • on success, connection is started

              It is so hard to read documentation????

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

              S 1 Reply Last reply 21 Dec 2020, 11:27
              6
              • S SPlatten
                21 Dec 2020, 10:42

                @ollarch , the IP exists on the system, but there is no application running listening for connection, nothing is using that port.

                J Offline
                J Offline
                J.Hilk
                Moderators
                wrote on 21 Dec 2020, 10:45 last edited by
                #7

                @SPlatten do you call connectToHost multiple times ? IIRC each connectTohost call may emit a HostFound signal


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                S 1 Reply Last reply 21 Dec 2020, 10:47
                0
                • J J.Hilk
                  21 Dec 2020, 10:45

                  @SPlatten do you call connectToHost multiple times ? IIRC each connectTohost call may emit a HostFound signal

                  S Offline
                  S Offline
                  SPlatten
                  wrote on 21 Dec 2020, 10:47 last edited by
                  #8

                  @J-Hilk I do call every 5 seconds.

                  Kind Regards,
                  Sy

                  1 Reply Last reply
                  0
                  • S SPlatten
                    21 Dec 2020, 10:42

                    @ollarch , the IP exists on the system, but there is no application running listening for connection, nothing is using that port.

                    O Offline
                    O Offline
                    ollarch
                    wrote on 21 Dec 2020, 11:16 last edited by
                    #9

                    @SPlatten said in QTcpSocket connecting even tho no server?:

                    @ollarch , the IP exists on the system, but there is no application running listening for connection, nothing is using that port.

                    So, the host is found.
                    As @KroMignon has told you a lot of times is to read the documentation.
                    It seems that you write some code, test, and if it fails you start writing a new thread in the forum.
                    Yes, I know that you have a lot work to do but this also applies to us.

                    S 1 Reply Last reply 21 Dec 2020, 11:19
                    5
                    • O ollarch
                      21 Dec 2020, 11:16

                      @SPlatten said in QTcpSocket connecting even tho no server?:

                      @ollarch , the IP exists on the system, but there is no application running listening for connection, nothing is using that port.

                      So, the host is found.
                      As @KroMignon has told you a lot of times is to read the documentation.
                      It seems that you write some code, test, and if it fails you start writing a new thread in the forum.
                      Yes, I know that you have a lot work to do but this also applies to us.

                      S Offline
                      S Offline
                      SPlatten
                      wrote on 21 Dec 2020, 11:19 last edited by SPlatten
                      #10

                      @ollarch, I have read the documentation, and nowhere does it say that the hostFound signal is issue when the IP is found regardless of the port!

                      The IP and Port combine make the address, the IP itself is no indication that there is anything to connect to, not if there is nothing using the specified port. And this information is not documented, hence my question.

                      Kind Regards,
                      Sy

                      JonBJ 1 Reply Last reply 21 Dec 2020, 12:06
                      0
                      • Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on 21 Dec 2020, 11:27 last edited by
                        #11

                        @SPlatten said in QTcpSocket connecting even tho no server?:

                        and nowhere does it say that the hostFound signal is issue when the IP is found regardless of the port!

                        Sorry but the error is called 'HostNotFound' - not 'Can not connect to host and port'...

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        1 Reply Last reply
                        0
                        • K KroMignon
                          21 Dec 2020, 10:45

                          @SPlatten said in QTcpSocket connecting even tho no server?:

                          From the Application Output I can see lots of Host Found! messages, is this normal when the IP:Port doesn't have anything listening to it?

                          Why do you never read documentation before asking what already describe in documentation?
                          Have you tried to read connectToHost() documentation (hint: just hit F1 key in Qt Creator):

                          Attempts to make a connection to hostName on the given port. The protocol parameter can be used to specify which network protocol to use (eg. IPv4 or IPv6).

                          The socket is opened in the given openMode and first enters HostLookupState, then performs a host name lookup of hostName. If the lookup succeeds, hostFound() is emitted and QAbstractSocket enters ConnectingState. It then attempts to connect to the address or addresses returned by the lookup. Finally, if a connection is established, QAbstractSocket enters ConnectedState and emits connected().

                          At any point, the socket can emit errorOccurred() to signal that an error occurred.

                          hostName may be an IP address in string form (e.g., "43.195.83.32"), or it may be a host name (e.g., "example.com"). QAbstractSocket will do a lookup only if required. port is in native byte order.

                          As you could read:

                          • the socket is opened, so QTcpSocket::isOpen() will return true
                          • hostname lookup is started ==> hostFound() is emitted on success
                          • on success, connection is started

                          It is so hard to read documentation????

                          S Offline
                          S Offline
                          SPlatten
                          wrote on 21 Dec 2020, 11:27 last edited by
                          #12

                          @KroMignon , I didn't say I never read the documentation, that's your inference and on this occasion I find that the documentation is not detailed enough. An address has two parts, the IP and the port.

                          Kind Regards,
                          Sy

                          K 1 Reply Last reply 21 Dec 2020, 11:45
                          0
                          • S SPlatten
                            21 Dec 2020, 11:27

                            @KroMignon , I didn't say I never read the documentation, that's your inference and on this occasion I find that the documentation is not detailed enough. An address has two parts, the IP and the port.

                            K Offline
                            K Offline
                            KroMignon
                            wrote on 21 Dec 2020, 11:45 last edited by
                            #13

                            @SPlatten said in QTcpSocket connecting even tho no server?:

                            I find that the documentation is not detailed enough. An address has two parts, the IP and the port.

                            It is written in documentation:
                            The socket is opened in the given openMode and first enters HostLookupState, then performs a host name lookup of hostName. If the lookup succeeds, hostFound() is emitted

                            => host name lookup, this is done before connection starts, so no need of TCP port.

                            This is very explicitly described in documentation.

                            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
                            6
                            • S SPlatten
                              21 Dec 2020, 11:19

                              @ollarch, I have read the documentation, and nowhere does it say that the hostFound signal is issue when the IP is found regardless of the port!

                              The IP and Port combine make the address, the IP itself is no indication that there is anything to connect to, not if there is nothing using the specified port. And this information is not documented, hence my question.

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on 21 Dec 2020, 12:06 last edited by JonB
                              #14

                              @SPlatten
                              I don't want to get into an argument, but it does say that.

                              https://doc.qt.io/qt-5/qabstractsocket.html#hostFound :

                              This signal is emitted after connectToHost() has been called and the host lookup has succeeded.

                              https://doc.qt.io/qt-5/qabstractsocket.html#connectToHost :

                              The socket is opened in the given openMode and first enters HostLookupState, then performs a host name lookup of hostName. If the lookup succeeds, hostFound() is emitted and QAbstractSocket enters ConnectingState. It then attempts to connect to the address or addresses returned by the lookup. Finally, if a connection is established, QAbstractSocket enters ConnectedState and emits connected().

                              So, as it says, hostFound signal is emitted on finding the host IP address. It does what it says on the packet, i.e. it's just a host lookup, by name or IP address, and tells you the host does exist.

                              Connecting on the port comes after that, and of course may succeed or fail separately.

                              Anyway, there it is, that's how it works.

                              S 1 Reply Last reply 21 Dec 2020, 14:43
                              2
                              • JonBJ JonB
                                21 Dec 2020, 12:06

                                @SPlatten
                                I don't want to get into an argument, but it does say that.

                                https://doc.qt.io/qt-5/qabstractsocket.html#hostFound :

                                This signal is emitted after connectToHost() has been called and the host lookup has succeeded.

                                https://doc.qt.io/qt-5/qabstractsocket.html#connectToHost :

                                The socket is opened in the given openMode and first enters HostLookupState, then performs a host name lookup of hostName. If the lookup succeeds, hostFound() is emitted and QAbstractSocket enters ConnectingState. It then attempts to connect to the address or addresses returned by the lookup. Finally, if a connection is established, QAbstractSocket enters ConnectedState and emits connected().

                                So, as it says, hostFound signal is emitted on finding the host IP address. It does what it says on the packet, i.e. it's just a host lookup, by name or IP address, and tells you the host does exist.

                                Connecting on the port comes after that, and of course may succeed or fail separately.

                                Anyway, there it is, that's how it works.

                                S Offline
                                S Offline
                                SPlatten
                                wrote on 21 Dec 2020, 14:43 last edited by
                                #15

                                @JonB , as I said previously the IP is just part of the address, the port completes the address, when you establish the connection the port is optional, but if supplied then it should be used because connecting to address and address:port are very different.

                                Kind Regards,
                                Sy

                                Christian EhrlicherC JonBJ K 3 Replies Last reply 21 Dec 2020, 14:46
                                0
                                • S SPlatten
                                  21 Dec 2020, 14:43

                                  @JonB , as I said previously the IP is just part of the address, the port completes the address, when you establish the connection the port is optional, but if supplied then it should be used because connecting to address and address:port are very different.

                                  Christian EhrlicherC Offline
                                  Christian EhrlicherC Offline
                                  Christian Ehrlicher
                                  Lifetime Qt Champion
                                  wrote on 21 Dec 2020, 14:46 last edited by
                                  #16

                                  @SPlatten said in QTcpSocket connecting even tho no server?:

                                  address:port

                                  This is wrong. It's host:port !

                                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                  Visit the Qt Academy at https://academy.qt.io/catalog

                                  S 1 Reply Last reply 21 Dec 2020, 15:14
                                  0
                                  • Christian EhrlicherC Christian Ehrlicher
                                    21 Dec 2020, 14:46

                                    @SPlatten said in QTcpSocket connecting even tho no server?:

                                    address:port

                                    This is wrong. It's host:port !

                                    S Offline
                                    S Offline
                                    SPlatten
                                    wrote on 21 Dec 2020, 15:14 last edited by
                                    #17

                                    @Christian-Ehrlicher , are you being piccy?

                                    Kind Regards,
                                    Sy

                                    1 Reply Last reply
                                    0
                                    • Christian EhrlicherC Offline
                                      Christian EhrlicherC Offline
                                      Christian Ehrlicher
                                      Lifetime Qt Champion
                                      wrote on 21 Dec 2020, 15:17 last edited by Christian Ehrlicher
                                      #18

                                      @SPlatten said in QTcpSocket connecting even tho no server?:

                                      are you being piccy?

                                      No, but your assumptions are wrong because of this wrong definition.

                                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                      Visit the Qt Academy at https://academy.qt.io/catalog

                                      1 Reply Last reply
                                      0
                                      • S SPlatten
                                        21 Dec 2020, 14:43

                                        @JonB , as I said previously the IP is just part of the address, the port completes the address, when you establish the connection the port is optional, but if supplied then it should be used because connecting to address and address:port are very different.

                                        JonBJ Offline
                                        JonBJ Offline
                                        JonB
                                        wrote on 21 Dec 2020, 16:05 last edited by JonB
                                        #19

                                        @SPlatten
                                        Sorry, Simon, you're incorrect. I did try to explain. I do know what IP addresses vs ports are. I was just pointing out, politely, that Qt's hostFound is emitted on host found, not on port is listening/connected. Anyways, it's not worth arguing about, we were just talking about how Qt documents what it is that it does when.

                                        1 Reply Last reply
                                        2
                                        • S SPlatten
                                          21 Dec 2020, 14:43

                                          @JonB , as I said previously the IP is just part of the address, the port completes the address, when you establish the connection the port is optional, but if supplied then it should be used because connecting to address and address:port are very different.

                                          K Offline
                                          K Offline
                                          KroMignon
                                          wrote on 21 Dec 2020, 16:37 last edited by
                                          #20

                                          @SPlatten said in QTcpSocket connecting even tho no server?:

                                          as I said previously the IP is just part of the address, the port completes the address, when you establish the connection the port is optional, but if supplied then it should be used because connecting to address and address:port are very different.

                                          Your are mixing up definitions:

                                          • Hostname is IP address or a name (like "www.qt.com")
                                          • portnum is the TCP port (number between 0 and 65534).
                                          • combination of hostname and TCP port is an Endpoint
                                          • a TCP connection is defined as a combination of 2 endpoints, the local endpoint and the remote endpoint

                                          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
                                          9

                                          3/28

                                          21 Dec 2020, 10:36

                                          topic:navigator.unread, 25
                                          • Login

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