Results 1 to 20 of 43

Thread: cannot read correct len from socket

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #16
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    15
    Thanked 16 Times in 15 Posts

    Default Re: cannot read correct len from socket

    Quote Originally Posted by wysota View Post
    If you are writing "47Saman" to the socket, what do you expect to receive as first four bytes on the other end of the communication?
    Wysota, client is sending me a jpeg file. in the server program, I used readAll() to read it all and pixmap it to a label. But, the image does not appear in the label (though the widget background flashes). To solve this, I was told that they would send the size of the jpeg file along with its content. Hence, I need to read the length first, and then realize how many bytes exactly to read.

    Qt Code:
    1. void MainWindow::readPixmap(QByteArray data)
    2. {
    3. QPixmap pm;
    4.  
    5. pm.loadFromData(data);
    6.  
    7. ui->label->setPixmap(pm);
    8. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by saman_artorious; 24th July 2013 at 18:57.

Similar Threads

  1. Replies: 6
    Last Post: 7th October 2012, 16:42
  2. Can't read from socket
    By marekdor in forum Newbie
    Replies: 6
    Last Post: 9th August 2012, 11:06
  3. Read all_ tcp socket
    By Mayssa in forum General Programming
    Replies: 1
    Last Post: 21st February 2012, 17:12
  4. Replies: 2
    Last Post: 22nd May 2011, 21:31
  5. socket read/write bytes
    By nowire75 in forum Newbie
    Replies: 3
    Last Post: 4th July 2007, 23:12

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.