[Qt-interest] does QAbstractSocket::disconnectFromHost() wait untill all data has been read ??
neel.basu.z at gmail.com
neel.basu.z at gmail.com
Thu Mar 12 18:28:36 CET 2009
On Thursday 12 March 2009 22:37:10 Thiago Macieira wrote:
> neel.basu.z at gmail.com wrote:
> >assuming I invoked QAbstractSocket::disconnectFromHost() just after
> > writting all requests.
> >e.g. I am looping through QList<QString> and writting each element of
> > the vector to the socket.
> >and when the loop finished I executed disconnectFromHost().
> >On the manual it says it garant's all data will be written before its
> > closed. But If the server is going to send some response after
> > recieving the last request would it reach to me ????
>
> That depends.
>
> QAbstractSocket will disconnect as soon as the last byte has been written
> to the socket. Anything received until that last byte will be available
> for reading, but not anything after.
>
> >cause when the last request has gone to server there is no unwritten
> > data in the buffer so disconnectFromHost() has no problem to close
> > (according to documentation).
> >So what will happen with the response that was coming from server.
>
> It will not be seen. You need to wait for that data without
> disconnectFromHost().
First of all thanks for your Reply
Hmm Though its not a Qt Specific Question.
Is it even possible to know is there anything still remaining to read ??
there are three possible problematic situations
1) server will Just eat up a particular message, e.g. would not send back any
response or feedback (which cannot be handled until explicitly stated by
client program)
2) all queued messages has been sent from server side and the server's
response for the last message is on the way but client has closed the
connection by invoking disconnectFromHost() (all data has been sent)
3) last message has been sent from client side and client has invoked
disconnectFromHost() but server is taking time to response (e.g. it is taking
time to MAKE the response)
No (1) is not much problem
How which of these circumstances are handlable and how ??
Thanks
Neel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090312/9bb3b126/attachment.html
More information about the Qt-interest-old
mailing list