QT 4.3 +VS2005:
{
Q_OBJECT
public:
~CFtp();
void CloseFtp();
private:
};
class CFtp: public QFtp
{
Q_OBJECT
public:
CFtp(QObject *parent = 0);
~CFtp();
qint16 ConnectToFTP(QString cFtpServer, QString cLogin, QString cPass);
void CloseFtp();
private:
QFtp *m_pFtp;
};
To copy to clipboard, switch view to plain text mode
void CFtp::CloseFtp()
{
m_pFtp->close();
//if(m_pFtp != NULL)
//delete(m_pFtp);
}
{
qint16 nStateConnect= -1;
qint16 nLoginConnect = -1;
nStateConnect = m_pFtp->connectToHost(cFtpServer);
nLoginConnect = m_pFtp->login(cLogin,cPass);
//QApplication::beep();
return 1;
}
void CFtp::CloseFtp()
{
m_pFtp->close();
//if(m_pFtp != NULL)
//delete(m_pFtp);
}
qint16 CFtp::ConnectToFTP(QString cFtpServer, QString cLogin, QString cPass)
{
m_pFtp = new QFtp;
qint16 nStateConnect= -1;
qint16 nLoginConnect = -1;
nStateConnect = m_pFtp->connectToHost(cFtpServer);
nLoginConnect = m_pFtp->login(cLogin,cPass);
//QApplication::beep();
return 1;
}
To copy to clipboard, switch view to plain text mode
void Connection::processReadyRead()
{
...
...
...
case 4: //DELETE FILE(4)
{
CFtp ftp;
ftp.ConnectToFTP("127.0.0.1","pas","amal");
ftp.CloseFtp();
}
break;
...
...
...
}
void Connection::processReadyRead()
{
...
...
...
case 4: //DELETE FILE(4)
{
CFtp ftp;
ftp.ConnectToFTP("127.0.0.1","pas","amal");
ftp.CloseFtp();
}
break;
...
...
...
}
To copy to clipboard, switch view to plain text mode
void FortuneThread::run()
{
Connection connection;
if(!connection.setSocketDescriptor(socketDescriptor))
{
emit error(connection.error());
return;
}
//connect(&connection, SIGNAL(SendMSG(QString)), this, SIGNAL(SendMSG(QString)));
connect(&connection, SIGNAL(disconnected()), this, SLOT(deleteConnection()));
exec();
}
void FortuneThread::run()
{
Connection connection;
if(!connection.setSocketDescriptor(socketDescriptor))
{
emit error(connection.error());
return;
}
//connect(&connection, SIGNAL(SendMSG(QString)), this, SIGNAL(SendMSG(QString)));
connect(&connection, SIGNAL(disconnected()), this, SLOT(deleteConnection()));
exec();
}
To copy to clipboard, switch view to plain text mode
But connection or occurs and hangs:
07/08/07 11:04:51, 499, 127.0.0.1, , new connection from 127.0.0.1 on 127.0.0.1:21
07/08/07 11:04:51, 499, 127.0.0.1, , hostname resolved : localhost
07/08/07 11:04:51, 499, 127.0.0.1, , sending welcome message.
07/08/07 11:04:51, 499, 127.0.0.1, , 220 Gene6 FTP Server v3.9.0 (Build 2) ready...
or it is not connected in general.
Connections are closed only after timeout or after closing the appendix.
Bookmarks