I'm developing an application that made sense that I wrapped my classes around the implemented QTcpSocket (since it's a TCP protocol, and I need to be able to use the raw socket and the added features as seemlessly as possible).
So, for the sake of simplicity, my code is structured like this:
class MyTCPSocket : public QTcpSocket
{
Q_OBJECT
// ....
}
class MyTCPServer : public QTcpServer
{
Q_OBJECT
// ....
}
And with QTcpServer, the default nextPendingConnection() function returns an instance of QTcpSocket, which I can't cast up to MyTCPSocket (as far as I'm aware, QTcpSocket doesn't have a copy constructure).
What's my best option for handing this? I was thinking that I could create a new MyTCPSocket and simply set the socket descriptor to the one returned by nextPendingConnection() from MyTCPServer, but I wasn't sure how that would work when the old socket gets deleted.
Is there a better way to handle this situation?