[Qt-interest] Socket communication without threads

Andreas Pakulat apaku at gmx.de
Mon Mar 2 16:45:10 CET 2009


On 02.03.09 16:36:27, Predrag Manojlovic wrote:
> Often i hear that threads should be avoided in qt socket applications.
> I'm not sure is that possible always.

Of course its not _always_ possible, but most of the time it is.

> I'm mostly creating applications like TCP chat client/server.
> 
> Questions:
> 1. Is there any way to create chat server without using threads?

Can't answer that one.

> 2. why is that better?

In general using only 1 thread is better because you avoid all
concurrent-access problems you get when having multiple threads. You don't
need to make sure you're accessing data only from one thread at a time,
debugging is a lot easier, you avoid a lot of possible timing issues
because sometimes one thread runs "faster" than another and causes a
problem.

Andreas

-- 
You will be a winner today.  Pick a fight with a four-year-old.



More information about the Qt-interest-old mailing list