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. QTcpServer Base class
QtWS25 Last Chance

QTcpServer Base class

Scheduled Pinned Locked Moved Solved General and Desktop
inheritanceabstract classqtcpserver
3 Posts 2 Posters 1.0k 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.
  • moffa13M Offline
    moffa13M Offline
    moffa13
    wrote on last edited by
    #1

    Hello,

    I'm creating an http server who can handle ssl or non ssl connections (boolean in the constructor) and I wanted to use either QTcpServer or SSLServer (class created by myself which inherits from QTcpServer) without changing my code

    So let's admit I have to do nextPendingConnection(); I don't want to do this :

    if(m_ssl){
        socket = dynamic_cast<SSLServer*>(m_tcpServer)->nextPendingConnection();
    }else{
        socket = m_tcpServer->nextPendingConnection();
    }
    

    but only m_tcpServer->nextPendingConnection(); and get the right type (either QTcpSocket or QSslSocket)

    So actually I think it's possible because I use functions existing in both classes but I don't know how to do achieve this.

    Thank you !

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @moffa13 said:

      QTcpSocket or QSslSocke

      but does QSslSocket not inherited QTcpSocket ?

      So if socket is
      QTcpSocket *socket

      it could point to a QSslSocke also and the correct nextPendingConnection() would be called
      pr normal resolve?

      1 Reply Last reply
      1
      • moffa13M Offline
        moffa13M Offline
        moffa13
        wrote on last edited by
        #3

        @mrjj said:

        but does QSslSocket not inherited QTcpSocket ?

        Yes, you're right thank you !

        1 Reply Last reply
        1

        • Login

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