Results 1 to 5 of 5

Thread: Problem in mp3 file receive by client application

  1. #1
    Join Date
    May 2010
    Posts
    46
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Exclamation Problem in mp3 file receive by client application

    I have the following client appln declaration -


    Qt Code:
    1. class clientapp : public QMainWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. clientapp(QWidget *parent = 0);
    7. ~clientapp();
    8.  
    9. public slots:
    10. void downloadFile();
    11. void fileDownloaded(QNetworkReply*);
    12.  
    13.  
    14. private:
    15. Ui::clientapp ui;
    16. QNetworkAccessManager *manager;
    17. QNetworkReply *reply;
    18. };
    To copy to clipboard, switch view to plain text mode 


    The implementation of the slots are as shown -

    Qt Code:
    1. void clientapp::downloadFile()
    2. {
    3. //download file
    4. //currently hardcoded
    5. connect(manager, SIGNAL(finished(QNetworkReply*)),
    6. this, SLOT(fileDownloaded(QNetworkReply*)));
    7.  
    8. reply = manager->get(QNetworkRequest(
    9. QUrl("http://10.225.208.185/ywr.mp3")));
    10.  
    11.  
    12. }
    13.  
    14. void clientapp::fileDownloaded( QNetworkReply* aHttpResponse )
    15. {
    16.  
    17. QByteArray data = aHttpResponse->readAll();
    18. QFile temp("E:\\httpresp.mp3");
    19. temp.open(QIODevice::WriteOnly | QIODevice::Truncate);
    20. temp.write(data);
    21. temp.close();
    22.  
    23.  
    24. }
    To copy to clipboard, switch view to plain text mode 

    The above code is trying to download an mp3 file from a server. The server on get sends the file, but the client application is not able to download & save the file. It has a trouble downloading any type of large file. What is the solution to this ?

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem in mp3 file receive by client application

    Perhaps it is not client issue, but server issue, did you confirm that the server sends all the bytes?

  3. #3
    Join Date
    May 2010
    Posts
    46
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Exclamation Re: Problem in mp3 file receive by client application

    I have seen that the server sends all the bytes. The problem is at the client end itself. Any solutions for this ?

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem in mp3 file receive by client application

    Yes, instead of trying to grab all the bytes at once, use readyRead signal and grab the bytes as they come in. Maybe it solves your problem.

  5. The following user says thank you to squidge for this useful post:

    ada10 (18th August 2010)

  6. #5
    Join Date
    May 2010
    Posts
    46
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Symbian S60

    Exclamation Re: Problem in mp3 file receive by client application

    Yes,using the readyRead() signal helped me to get the mp3 files. Works well with large sized files also. Thanks a lot.

Similar Threads

  1. Replies: 8
    Last Post: 19th January 2010, 12:50
  2. Receive file over TCP
    By winarko in forum Qt Programming
    Replies: 18
    Last Post: 29th May 2008, 17:25
  3. TCP Client-Server Application
    By Tavit in forum Qt Programming
    Replies: 1
    Last Post: 18th March 2008, 13:20
  4. Client-Server Application design suggestion
    By berzeck in forum Qt Programming
    Replies: 6
    Last Post: 17th December 2007, 18:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.