Hi, i need to implement a ftp client that has a resume upload feature using QFtp.

I have tried implementing the resume function using raw commands ... something like the following:

Qt Code:
  1. ftp->rawCommand("TYPE I");
  2. ftp->rawCommand("PASV");
  3. ftp->rawCommand("REST" + x); //where x is the string with the position ...
  4. ftp->rawCommand("STOR" + remoteFileName);
To copy to clipboard, switch view to plain text mode 

however i am getting the following error:

425 :: "Can't open data connection."

I have looked over the QFtp sourcefile and i saw that the ftp data channel isn't opened when using raw commands.
I have tried opening a data channel using a QTcpSocket like this :

Qt Code:
  1. void FtpClass::onRawCmdReply(int replyCode, const QString & detail )
  2. {
  3. qDebug() << replyCode << " :: " << detail;
  4.  
  5. if (replyCode == 227) // detail = Entering Passive Mode (a1,a2,a3,a4,p1,p2)
  6. // host = a1.a2.a3.a4
  7. // port = p1*256 + p2
  8. {
  9. QRegExp addrPortPattern(QLatin1String("(\\d+),(\\d+),(\\d+),(\\d+),(\\d+),(\\d+)"));
  10. if (addrPortPattern.indexIn(detail) == -1)
  11. {
  12. {
  13. qDebug("QFtp: bad 227 response -- address and port information missing");
  14. }
  15. }
  16. else
  17. {
  18. _dataSocket = new QTcpSocket(this);
  19. QStringList lst = addrPortPattern.capturedTexts();
  20. QString host = lst[1] + QLatin1Char('.') + lst[2] + QLatin1Char('.') + lst[3] + QLatin1Char('.') + lst[4];
  21. quint16 port = (lst[5].toUInt() << 8) + lst[6].toUInt();
  22. _dataSocket->connectToHost(host, port);
  23. if (!_dataSocket->waitForConnected(1000))
  24. {
  25. qDebug() << "cannot connect to: " << host << "port :" << port;
  26. }
  27. else
  28. {
  29. qDebug() << "connected to: " << host << "port :" << port;
  30. }
  31. }
  32. }
  33. }
To copy to clipboard, switch view to plain text mode 


But if i do that i get the following error :

426 :: "Connection closed; transfer aborted."

It is not a server issue since i've tested using a random ftp client and the server supports resuming.
Also it is not a firewall issue since i dissabled the firewalls on both machines.

What am i doing wrong ? can someone help me please?