[Development] Common base class for all socket types

Thiago Macieira thiago.macieira at intel.com
Tue Nov 6 21:56:37 CET 2012


On terça-feira, 6 de novembro de 2012 11.49.40, Alfonso Chartier wrote:
> Someone below asked what the motivation is behind having a common abstract
> socket base class for all concrete socket types. The reason for this is it
> can significantly clean up client code. Currently if I want to handle
> different sockets generically (e.g., TCP vs. local), I have to jump through
> several hurdles: create my own wrapper class abstraction, maintain separate
> lists of objects, etc. A single, common base class would allow client code
> to use polymorphism to manage and use socket objects very easily. For
> instance, I could then have client code that defines a
> QList<QAbstractSocket*> and is able to connect, disconnect, write, read,
> etc. from the socket without having to know the concrete class type.
> 
> I hope this helps explain why it would be very useful to have a common base
> socket class.

It's very clear why you'd want to have a common base class, but you were not 
concrete on the details. I want to know what methods from QAbstractSocket 
and/or QLocalSocket would you like to see in this common base class, methods 
that aren't in QIODevice.

Or, asked from another angle: why you can't use QList<QIODevice *> in your 
case above? You said disconnect, read, write, all of which you can do with 
QIODevice (close() is virtual, the signals are in QIODevice).
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20121106/d46543e0/attachment.sig>


More information about the Development mailing list