Results 1 to 3 of 3

Thread: QT Socket programming

  1. #1
    Join Date
    Aug 2012
    Posts
    4
    Qt products
    Qt3 Qt4

    Default QT Socket programming

    i am receiving large structure (sizeof structure is around 130024) in a QT server programme from non-qt client. But it receives only 50176 bytes out of 130024 bytes sent from client. i am using qsocket.read() at qt server. i had tried sending of the struct in slices of 1460 bytes and but still i am able to receive only 50176 bytes at my QT programme. The size of receiving buffer is 130024 bytes.

    QTcpSocket qsocket ;
    if (!qsocket.setSocketDescriptor(socketDescriptor))
    {
    emit error(qsocket.error());
    return;
    }
    QHostAddress clientt_adrr = qsocket.peerAddress();
    QString client_adrr = clientt_adrr.toString();
    while(1)
    { if(qsocket.bytesAvailable())
    {
    data_sz1 = qsocket.read(Rawbuf, sizeof(struct Result));
    }
    }

    size of struct Result is 130024 bytes.
    Please help me to resolve this problem.
    thanks..

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QT Socket programming

    Why did you create a new thread with the same question as the one you started on August 24th?

    I replied to your first thread. It seems that you never bothered reading the page to which I linked there. If you had, you would know that you are dealing with the so-called "framing problem".

    Your code cannot work because the socket is meant to be used asynchronously and you have to return to the event loop and wait for the socket to emit its readyRead() signal. You may also go for a synchronous approach, but then you have to call waitForReadyRead() to wait until data is available.

    I suggest you read the documentation for QAbstractSocket and check out the network examples mentioned there.

    Last but not least, please show some interest in solving your own problem by at least trying to follow the advice others give you. Spamming the forum until someone posts a complete solution is a path to disappointment.

  3. #3
    Join Date
    Aug 2012
    Posts
    4
    Qt products
    Qt3 Qt4

    Default Re: QT Socket programming

    sorry for this...
    I thought i may not get reply if i'll use the old thread..that's why i created a new thread..
    Thanks for your solution...
    when i am using waitForReadyRead() its working...

Similar Threads

  1. TQ Socket Programming
    By praveen1 in forum Newbie
    Replies: 1
    Last Post: 24th August 2012, 10:24
  2. Socket programming
    By isharasjc in forum General Discussion
    Replies: 5
    Last Post: 21st March 2012, 09:03
  3. socket programming
    By Arpitgarg in forum Newbie
    Replies: 13
    Last Post: 21st April 2011, 09:25
  4. Socket programming, please help me!
    By nthung in forum Qt Programming
    Replies: 21
    Last Post: 26th May 2010, 23:01
  5. Can any One help me? - Socket Programming?
    By vinod in forum Qt Programming
    Replies: 6
    Last Post: 18th November 2009, 09:46

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.