Multithreaded QLocalSocket

Kevin Krammer kevin.krammer at gmx.at
Sun Jun 29 13:19:21 BST 2008


On Sunday 29 June 2008, Sebastian TrĂ¼g wrote:
> Apparently on Unix QLocalSocket uses QTcpSocket internally. This results in
> a big problem when I want to use it in a multithreaded environment as I
> cannot move the internal QTcpSocket to the new thread. Does anyone have an
> idea on how to solve this issue? On how to use QLocalSocket in
> multithreaded systems?

On the server or the client side?

On the client side you could use one QLocalSocket per thread.

On the server side you can use the incomingConnection(quintptr) template 
method of QLocalServer and create the actual QLocalSocket in the target 
thread's context. We do this in Akonadi, see 
kdesupport/akonadi/server/src/akonadi.cpp and 
kdesupport/akonadi/server/src/akonadiconnection.cpp

Cheers,
Kevin
-- 
Kevin Krammer, KDE developer, xdg-utils developer
KDE user support, developer mentoring
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080629/481be306/attachment.sig>


More information about the kde-core-devel mailing list