C++ (Qt)QSocketNotifier: Invalid socket specifiedQSocketNotifier: Internal error
C++ (Qt)void SocketListener::addConnection_p (QTcpSocket *socket){ connect (socket, SIGNAL (readyRead()), SLOT (readyRead())); connect (socket, SIGNAL (disconnected()), SLOT (disconnected())); sockets_.push_back ( {socket, false}); qDebug () << "New connection" << socket->peerAddress ();} void SocketListener::readyRead(){ QTcpSocket *socket = qobject_cast <QTcpSocket *> (sender ()); Q_CHECK_PTR (socket); do { const QString reply = Utils::readLineFromSocket (socket); if (!replyAnalizer_.setReply (reply, socket)) { qWarning () << "Socket reply is incorrect" << reply; socket->disconnectFromHost (); } } while (socket->canReadLine ());} void SocketListener::disconnected(){ QTcpSocket *socket = qobject_cast <QTcpSocket *> (sender ()); Q_CHECK_PTR (socket); qDebug () << "Closed connection" << socket->peerAddress (); socket->deleteLater (); sockets_.erase (findSocket (socket));} SocketListener::Sockets::iterator SocketListener::findSocket (QTcpSocket *socket){ return std::find_if (sockets_.begin(), sockets_.end(), [socket] (const Socket & s) -> bool { return s.first == socket; } );}