[Qt-interest] QTcpServer in fortuneserver example

pmqt71 pmqt71 at gmail.com
Wed Feb 2 13:26:42 CET 2011


Hi,
the fortuneserver in qt 4.6.2 uses QTcpServer and accepts client connections
without using threads :


   tcpServer = new QTcpServer(this);
   if (!tcpServer->listen()) {
       ...
   }

   ...
   connect(tcpServer, SIGNAL(newConnection()), this, SLOT(sendFortune()));
   ...

   void Server::sendFortune()
   {
       QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
       ...
       clientConnection->write(block);
   }


My question is: in this example, what QTcpServer does in case of concurrent
client connections? Is it able to serialize them? The sendFortune method can
access shared memory without protecting the critical section?

thanks
pm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110202/15da6f83/attachment.html 


More information about the Qt-interest-old mailing list