Results 1 to 4 of 4

Thread: transfer large files using qsocket

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Location
    Chennai, India
    Posts
    25
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    1

    Default transfer large files using qsocket

    how to transfer large files using QSocket

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: transfer large files using qsocket

    Could you provide any details on what you have already tried to achieve the goal? I believe there are examples bundled with Qt that describe how to use QSocket.

  3. #3
    Join Date
    Jan 2007
    Location
    Chennai, India
    Posts
    25
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    1

    Question Re: transfer large files using qsocket

    hi,
    this is the code for upload a file from client side to server side

    Qt Code:
    1. /*! Used to upload a file */
    2. void ACMClient::fileUpload(QString &a_fileToSend)
    3. {
    4. QFile l_file(a_fileToSend);
    5.  
    6. if(l_file.exists())
    7. {
    8. if ( l_file.open(IO_ReadOnly ) )
    9. {
    10. QByteArray l_byteArray = l_file.readAll();
    11.  
    12. l_byteArray = qCompress(l_byteArray);
    13. QString l_string(l_byteArray);
    14. QString l_byteArraySize;
    15. l_byteArraySize.setNum(l_byteArray.size(),10);
    16.  
    17. QMessageBox::information(this, "FTP", l_byteArraySize);
    18. m_socket->writeBlock( l_byteArray,l_byteArray.size() );
    19. }
    20. }
    21. }
    To copy to clipboard, switch view to plain text mode 

    it can read all bytes but QServer socket read only minimum amount of bytes.
    what is solution for read all bytes ?
    Last edited by jacek; 2nd March 2007 at 15:37. Reason: missing [code] tags

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: transfer large files using qsocket

    Quote Originally Posted by vishesh View Post
    it can read all bytes but QServer socket read only minimum amount of bytes.
    How do you read the data on the server? Are you aware that the data might arrive in several chunks that you have to merge?

Similar Threads

  1. fast writing of large amounts of data to files
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2007, 16:33
  2. Replies: 5
    Last Post: 22nd September 2006, 08:04
  3. [Win32/VC++ 8.0] Strange problems with qrc_*.cpp files
    By mloskot in forum Installation and Deployment
    Replies: 6
    Last Post: 6th March 2006, 10:28

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
  •  
Qt is a trademark of The Qt Company.