[Qt-interest] QLocalSocket is not from Abstract?

Giuseppe D'Angelo dangelog at gmail.com
Fri Oct 21 00:36:10 CEST 2011


On 20 October 2011 21:54, Jason H <scorp1us at yahoo.com> wrote:
> I was looking at adding a local socket to a tcp server that I have. Simple
> enough:
> server -> connector (for handling new connection signals) -> handler (takes
> a QAbstractSocket)
> This design works well because I can use the connector for http and https.
> So I thought simple, I'll just add a tweak for QLocalSocket. Well no joy
> because QLocalSocket does not inherit from QAbstractSocket, even though they
> have the same newConnection() signal and many other features. Does anyone
> know why this is?

QAbstractSocket isn't actually a general-purpose socket abstraction,
rather an abstraction of an internet socket (i.e. AF_INET) -- for
instance, note that all the methods that deal with addresses actually
carry IP addresses (QHostAddress), it embeds the concepts of
local/peer ports as unsigned shorts, etc. In short: not suitable for
local (AF_UNIX) sockets, although it still has a huge degree of
"static polymorphism" w.r.t. QLocalSocket. I read somewhere that the
decision of making QAbstractSocket was a poor choice, but I can't find
that source right now.

Cheers,
-- 
Giuseppe D'Angelo



More information about the Qt-interest-old mailing list