[Interest] QLocalSocket bug?

Etienne Sandré-Chardonnal etienne.sandre at m4x.org
Tue Jan 5 17:20:14 CET 2016


Hi,

I am adapting existing code from QTcpSocket to QLocalSocket (The TCP code
was used for distributing computations over a network, but since I also
want to separate the local computation in a sub-process, I'm using the TCP
code for IPC using QLocalSocket).

On the server side, the readyRead() signal is connected to an
incomingData() slot which processes data using a loop:

while(socket->canReadLine())
{
    command = socket->readLine();
    processCommand(command);
}

Now, when the connection gets closed, I am receiving a readyRead() signal
after the socket is closed (this is confirmed by socket->isReadable() which
is false)

But still, socket->canReadLine() returns true, and socket->readLine()
returns an empty string, which leads to an infinite loop.

I can fix this by adding socket->isReadable() in the loop condition, but I
am wondering if this is a QLocalSocket bug that should be filed.

Also, why is QLocalSocket not inheriting QAbstractSocket? They share a very
similar interface, this would make things easier when developing somethinh
which would use seamlessly network sockets and local pipes.


Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160105/3681c9d4/attachment.html>


More information about the Interest mailing list