From kde-devel Fri Sep 19 06:31:43 2008 From: Thiago Macieira Date: Fri, 19 Sep 2008 06:31:43 +0000 To: kde-devel Subject: Re: How to move large data inside a protocol over tcp using Qt/KDE? Message-Id: <200809190831.43347.thiago () kde ! org> X-MARC-Message: https://marc.info/?l=kde-devel&m=122180597400546 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============1009337937==" --===============1009337937== Content-Type: multipart/signed; boundary="nextPart1430286.xaLJuHXUdS"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart1430286.xaLJuHXUdS Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Matthew Woehlke wrote: >Probably Qt polls the socket for you as part of the event loop, hence >the readyRead signal. Assuming Qt supports non-blocking sockets (which >it *really* should), you just keep trying to read until you get less >bytes back than you asked for. Normally you take the little buffers and >use them to progressively fill a larger buffer until you have an entire >"message". At that point, you deal with the message, do a memmove to >shift the buffer contents back to the beginning, and repeat until you >have reason to stop. That's how it works. The sockets are non-blocking, always. And when the function doing the=20 reading (QAbstractSocketPrivate::canReadNotification()) is called, it=20 will read until it gets a -1 EWOULDBLOCK. When it gets that, it emits=20 readyRead(). So readyRead() is emitted once there's data to be read. Unlike a socket=20 polling, if you don't read the data, you won't be reminded again. The=20 signal emits again only when more data arrives. =2D-=20 =A0 Thiago Macieira =A0- =A0thiago (AT) macieira.info - thiago (AT) kde.org =A0 =A0 PGP/GPG: 0x6EF45358; fingerprint: =A0 =A0 E067 918B B660 DBD1 105C =A0966C 33F5 F005 6EF4 5358 --nextPart1430286.xaLJuHXUdS Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iD8DBQBI00dPM/XwBW70U1gRAlhtAJwJfWttzD2ROkqCfBwVcQdWm84OIQCfTv5I bQFJShaCV1N4YAONbi7SGyo= =6Ume -----END PGP SIGNATURE----- --nextPart1430286.xaLJuHXUdS-- --===============1009337937== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << --===============1009337937==--