[Development] Common base class for all socket types

d3fault d3faultdotxbe at gmail.com
Tue Nov 6 02:27:14 CET 2012


+1

It's now or never (well... 6... so like 2020 lol?)

A 'server' that can listen to clients that are both:
a) other processes on the same machine
b) other machines on the network
at the same time by working with a common abstract base type would be
very handy.



Unifying the connectTo* methods is the biggest concern. QLocalSocket
does not have a port. Unifying the localSocketName + hostName is easy
though.


Here's the design that keeps being mentioned:

class QAbstractSocket;
class QLocalSocket : QAbstractSocket;
class QAbstractNetworkSocket : QAbstractSocket;
class QTcpSocket : QAbstractNetworkSocket
class QUdpSocket : QAbstractNetworkSocket

^^^EDIT: renamed most of these below

A question mark in my brain is whether or not QLocalSocket should
derive from a QAbstractLocalSocket. Surely there are multiple ways to
do a local socket (hypothetically: an ugly wrapper around
QSharedMemory :-P (or you could also just specify which to use as a
constructor parameter in QLocalSocket too.... but OH WAIT THAT'S
EXACTLY WHY the current QAbstractSocket design fails. I say it's
better to have and to not need [...])).

So screw it, +1 on QAbstractLocalSocket (derives from QAbstractSocket
ofc) type too. We can't predict the future, as is evident by the
discussion we are having.


...perhaps we should take the word 'socket' out of the impl of
QLocalSocket, since a named pipe isn't one.

how about:
class QLocalFifo : QAbstractLocalSocket : QAbstractSocket;

idk what the perfect name for that would be. QLocalPipe (but the unix
variants really are sockets!)? QLocalDataChannel as mentioned in the
page OP links to (this would now imply QAbstractDataChannel as the
common base)?


re-design + rename:
class QAbstractDataChannel;
class QAbstractLocalDataChannel : QAbstractDataChannel;
class QAbstractNetworkDataChannel : QAbstractDataChannel;
class QNamedPipeOrLocalSocket : QAbstractLocalDataChannel; //this name sucks.
class QTcpSocket : QAbstractNetworkDataChannel;
class QUdpSocket : QAbstractNetworkDataChannel;

and just to demonstrate the 'hypothetical' purpose of
QAbstractLocalDataChannel---
class QSharedMemoryDataChannel : QAbstractLocalDataChannel;
^^I'm not saying we actually implement that (but we could), just that
we cannot predict what the future will hold.


As an aside, while I'm on the subject: Which is faster? QSharedMemory
or QLocalSocket?


d3fault
unprecedented precedence preceding price



More information about the Development mailing list