[Qt-interest] Receive an ASCII string using TcpSocket
Arnold Krille
arnold at arnoldarts.de
Mon Apr 13 21:51:06 CEST 2009
Hi,
On Monday 13 April 2009 20:51:47 Stefanos Antaris wrote:
> I can connect to the server.But i can't read any string.I am using the
> fortuneclient example.But in the readFortune() function i use this
> command despite of the QDataStream in(tcpSocket);
> [code]
> QString text;
> text=tcpSocket.readLine();
> [/code]
Is the server actually sending a \n-terminated string? Otherwise readLine will
wait forever.
Why don't you use the read-functions that read into QByteArray? Because
actually the server isn't sending a QString (if its not implemented in Qt) but
probably a zero-terminated stream of bytes. And its your fun to make something
usable of it.
All (or at least most) of the Qt-functions to send Qt-types over QIODevice
only work if both sides are Qt, I think.
Have fun,
Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090413/55f0a3e1/attachment.bin
More information about the Qt-interest-old
mailing list