Qt4-preview-feedback Archive, April 2007
What about m_Socket->waitForBytesWritten()?
Message 1 in thread
Hello,
I am wondering if waitForBytesWritten() works for QSocket or not. Assistant
says
"For buffered devices, this function waits.."
and
"QTcpSocket does not support Unbuffered mode"
so this would mean it should work. But it doesn't. I call it like
m_Socket->waitForBytesWritten(-1)
so the application should hang, but I get immediate false. Any hint?
To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx
Message 2 in thread
Hello,
I am wondering if waitForBytesWritten() works for QSocket or not. Assistant
says
"For buffered devices, this function waits.."
and
"QTcpSocket does not support Unbuffered mode"
so this would mean it should work. But it doesn't. I call it like
m_Socket->waitForBytesWritten(-1)
so the application should hang, but I get immediate false. Any hint?
To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx
Message 3 in thread
Hello again,
waitForReadyRead does not work either on Sockets. I took the fortune example,
which is imho really too easy to explain something, and tried to send a
message and reply to it... it does not work.
Is there any magic to get a synchronous socket communication?
On Wednesday 18 April 2007 10:41:33 J. Preiss wrote:
> Hello,
>
> I am wondering if waitForBytesWritten() works for QSocket or not. Assistant
> says
> "For buffered devices, this function waits.."
> and
> "QTcpSocket does not support Unbuffered mode"
>
> so this would mean it should work. But it doesn't. I call it like
> m_Socket->waitForBytesWritten(-1)
> so the application should hang, but I get immediate false. Any hint?
>
> To unsubscribe - send "unsubscribe" in the subject to
> qt4-preview-feedback-request@xxxxxxxxxxxxx
To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx
Message 4 in thread
J. Preiss wrote:
> Hello again,
> waitForReadyRead does not work either on Sockets. I took the fortune
> example, which is imho really too easy to explain something, and tried to
> send a message and reply to it... it does not work.
> Is there any magic to get a synchronous socket communication?
Hm, no those classes should work perfectly. We have 0 test failures for any
of the socket classes. Could you show some code that fails, and maybe we
can track it down?
Andreas
--
[ signature omitted ]
Message 5 in thread
On Thursday 19 April 2007 16:52:46 Andreas Aardal Hanssen wrote:
> J. Preiss wrote:
> > Hello again,
> > waitForReadyRead does not work either on Sockets. I took the fortune
> > example, which is imho really too easy to explain something, and tried to
> > send a message and reply to it... it does not work.
> > Is there any magic to get a synchronous socket communication?
>
> Hm, no those classes should work perfectly. We have 0 test failures for any
> of the socket classes. Could you show some code that fails, and maybe we
> can track it down?
I found "the error" in waitForBytesWritten(): I did a flush on the socket
before, so there was probably nothing left to write:
// m_Socket->flush();
qDebug() << "TTcpClient, Wait for write";
bool ret = m_Socket->waitForBytesWritten(m_Timeout);
So this works now.
To check waitForReadyRead, just insert the command in the fortuneclient
(client.cpp, line 93):
in.setVersion(QDataStream::Qt_4_0);
if( !tcpSocket->waitForReadyRead(3000) )
{
qDebug() << "no bytes to read";
return;
}
if (blockSize == 0) {
... and you won't see any fortune anymore... Is it possible, that a
QCoreApplication::processEvents is missing in that function?
I need this in the case that I send a message and wait for the reply. Then it
happens that the answer is not yet there, but I have to wait for a few
seconds.
To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx
Message 6 in thread
J. Preiss wrote:
> if( !tcpSocket->waitForReadyRead(3000) )
This function returns whether readyRead() was emitted while waiting, or in
the case of being called as a /result of/ readyRead() being emitted, it
returns true only if /more/ data has arrived (since Q*Socket does not emit
readyRead() recursively). So in this example, it makes sense that this call
returns false... The minimal payload of a fortune message has a very high
likelihood of arriving in one packet, so by the time you call
waitForReadyRead(), there's no more incoming data to wait for :-).
Hope that helps :-).
Andreas
--
[ signature omitted ]