Results 1 to 2 of 2

Thread: QTcpServer::hasPendingConnections () - socket creation issue

  1. #1
    Join Date
    Jan 2008
    Posts
    107
    Thanks
    36
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question QTcpServer::hasPendingConnections () - socket creation issue

    Dear All,

    From the fine QT manual:
    "This virtual function is called by QTcpServer when a new connection is available. The socketDescriptor argument is the native socket descriptor for the accepted connection.
    The base implementation creates a QTcpSocket, sets the socket descriptor and then stores the QTcpSocket in an internal list of pending connections. Finally newConnection() is emitted.
    Reimplement this function to alter the server's behavior when a connection is available.
    "

    Now the question is:
    reimplementing the function prevents the creation of a QTcpSocket? -- meaning that I'm only interested in the socketDescriptor for passing it into another thread and creating the socket there...

    Regards,
    Pedro Doria Meunier

  2. #2
    Join Date
    Aug 2006
    Location
    Germany
    Posts
    33
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTcpServer::hasPendingConnections () - socket creation issue

    I didnt get u fully.

    here is how u do

    u have to modify the incomingconnection(int socketDescriptor).

    create a class:

    Qt Code:
    1. class CTest: public QTcpServer
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. CTest(QObject *parent = 0);
    7.  
    8. protected:
    9. void incomingConnection(int socketDescriptor);
    10. }
    To copy to clipboard, switch view to plain text mode 

    From ur main application, derive the pointer or object of this class and then start server by listening.

    Then u will get socketDescriptor everytime a new client connect.

    Hope this helps.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.