[Qt-interest] QTcpSocket weirdness

Thiago Macieira thiago at kde.org
Fri Apr 2 18:53:50 CEST 2010


Em Quinta-feira 1. Abril 2010, às 05.20.19, Anatoly Burakov escreveu:
> My application uses QtNetwork and QTcpServer/QTcpSocket in order to
> communicate. The server and client use a custom connection protocol
> (made of integers and objects). The server side is structured as a lot
> of nested switch/case statements (that is, i can't imagine use of QT
> signal/slot mechanism in such situation) and resides on a separate
> thread (nextPendingConnection etc). The whole idea looks something like
> this:

I guess threading is your problem. As a friend put it "if you had a problem 
and you added threads to your program, now you have two problems".

Make sure that the QTcpServer is created on the same thread that you're trying 
to use the QTcpSocket objects from. Otherwise, you have race conditions all 
over the place.

If that doesn't solve the problem, please post some code examples. Your 
explanation is quite complete, but we're getting everything through your 
filter. We need to see the code to understand where the problem is.

PS: make sure your code samples are less than 200 lines of code (200 for 
client, 200 for server).
-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100402/55ab97e8/attachment.bin 


More information about the Qt-interest-old mailing list