//delete socket;
void Seab::connectToServer(){ if (connectedToServer) { clientSocket->disconnectFromHost(); delete clientSicket; connected ToServer = false; } else { clientSocket = new QTcpSocket(this); connect(clientSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(connectError(QAbstractSocket::SocketError))); clientSocket->connectToHost(address, 54545); connectedToServer = true; }}
void Seab::connectError(QAbstractSocket::SocketError socketError){ if (socketError == QAbstractSocket::RemoteHostClosedError) QMessageBox::information(this, "Error!", "Remote Host Closed"); if (socketError == QAbstractSocket::HostNotFoundError) QMessageBox::information(this, "Error!", "Host not found"); else QMessageBox::information(this, "Error!", "Error"); if (connectedToHost) { clientSocket->disconnectFromHost(); delete clientSocket; connectedToHost = false; }}