src/network/socket/qtcpserver.cpp
changeset 30 5dc02b23752f
parent 22 79de32ba3296
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
   560     \note If you want to handle an incoming connection as a new QTcpSocket
   560     \note If you want to handle an incoming connection as a new QTcpSocket
   561     object in another thread you have to pass the socketDescriptor
   561     object in another thread you have to pass the socketDescriptor
   562     to the other thread and create the QTcpSocket object there and
   562     to the other thread and create the QTcpSocket object there and
   563     use its setSocketDescriptor() method.
   563     use its setSocketDescriptor() method.
   564 
   564 
   565     \sa newConnection(), nextPendingConnection()
   565     \sa newConnection(), nextPendingConnection(), addPendingConnection()
   566 */
   566 */
   567 void QTcpServer::incomingConnection(int socketDescriptor)
   567 void QTcpServer::incomingConnection(int socketDescriptor)
   568 {
   568 {
   569 #if defined (QTCPSERVER_DEBUG)
   569 #if defined (QTCPSERVER_DEBUG)
   570     qDebug("QTcpServer::incomingConnection(%i)", socketDescriptor);
   570     qDebug("QTcpServer::incomingConnection(%i)", socketDescriptor);
   571 #endif
   571 #endif
   572 
   572 
   573     QTcpSocket *socket = new QTcpSocket(this);
   573     QTcpSocket *socket = new QTcpSocket(this);
   574     socket->setSocketDescriptor(socketDescriptor);
   574     socket->setSocketDescriptor(socketDescriptor);
       
   575     addPendingConnection(socket);
       
   576 }
       
   577 
       
   578 /*!
       
   579     This function is called by QTcpServer::incomingConnection()
       
   580     to add a socket to the list of pending incoming connections.
       
   581 
       
   582     \note Don't forget to call this member from reimplemented
       
   583     incomingConnection() if you do not want to break the
       
   584     Pending Connections mechanism.
       
   585 
       
   586     \sa incomingConnection()
       
   587     \since 4.7
       
   588 */
       
   589 void QTcpServer::addPendingConnection(QTcpSocket* socket)
       
   590 {
   575     d_func()->pendingConnections.append(socket);
   591     d_func()->pendingConnections.append(socket);
   576 }
   592 }
   577 
   593 
   578 /*!
   594 /*!
   579     Sets the maximum number of pending accepted connections to \a
   595     Sets the maximum number of pending accepted connections to \a