[Qt-interest] slot connected to QAbstractSocket::QIODevice::readyRead () recieves multiple responses at once

Neel Basu neel.basu.z at gmail.com
Wed Apr 15 14:22:05 CEST 2009


On Wednesday 15 April 2009 17:33:04 Andreas Pakulat wrote:
> On 15.04.09 17:18:31, Neel Basu wrote:
> > Suppose I am sending
> > ---> Request1 CRLF
> > Server will responding the following multiple messages on that Request1
> > <--- Response1 CRLF
> > <--- Response2 CRLF
> > <--- Response3 CRLF
> > Now readyRead() should emit 3 times
> > But SOMETIMES (rare but not so rare to ignore) readyRead() emits less
> > than 3 times
> >
> > sometimes it emits just Once for all these three Responses and If I
> > invoke readAll() it returns Response1 CRLF Response2 CRLF Response3 CRLF
> > as one response
> >
> > Its not possible to distinguish them anyway other than CRLF.
> >
> > But its not Mandatory for a Protocol to end all of its messages with CRLF
> > (* I am not sure on this point Please Correct me If I am wrong)
>
> There's a difference between a protocol's definition of "one message" and
> an amount of bytes being sent over the socket. The latter is what gets
> signalled by readyRead, the socket has data available. Wether that is one
> of your responses or multiple depends on, how fast the server sent the
> stuff, how fast your network is, how large the responses are (i.e. how fast
> they fill up any internal buffers in the network stacks).
>
> So the fact that you get only 1 emit and all the data in one go is quite
> normal. If you want to implement some kind of protocol, then you need to
> split up the received bytes yourself into individual responses.
>
> > So Whats the general solution to separate them.
>
> There is none, because how to split up the received binary data depends on
> the protocol you want to use.
>
> Andreas
Well Two non-Qt Question and 1 Qt Question:
is it Mandatory for a Protocol to end all of its messages with CRLF or with 
any Specified tailer

If a big response is splitted into multiple messages would they have the same 
Acknowledgement Number

will bytesAvailable() methods return the size of first message or all messages 
currently stored in the buffer in the above mentioned Scenario.

Thanks
Neel



More information about the Qt-interest-old mailing list