[Qt-interest] Socket communication without threads

Scott Aron Bloom Scott.Bloom at sabgroup.com
Tue Mar 3 21:01:34 CET 2009


> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Arnold Krille
> Sent: Tuesday, March 03, 2009 11:41 AM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Socket communication without threads
> 
> Hi,
> 
> On Tuesday 03 March 2009 18:35:54 Roland Krause wrote:
> > There is an additional problem here with the block size at least for
> > QLocalSocket. I've been experimenting with it and noticed that if
you
> > send a large block of data at a time, you have to manually process
> > events in order to receive all the data in one go. It seems that the
> > readyRead signal is emitted and when you call read(char * data,
> > quint64  size) you can only get as much data as was in the buffer at
> > the time of the call which must not necessarily be all the data that
was
> written.
> 
> You really expect the network driver or glibc or Qt to have buffers in
memory
> of several hundred megabytes???
> 
> > I am going to try the same with QTcpSocket next and see whether the
> > problem is the same there (it should afaict from looking at the
> > implementation of QLocalSocket).
> > Anyway, I believe for large amounts of payload data a threaded
> > implementation could be warranted.
> 
> Still no need for threads. Just create your own buffer which you
append data
> to inside the slot connected to readyRead(). Once a full dataset is in
the
> buffer you can trigger processing (while the next dataset might be
appended by
> readyRead()). Why would you want several (explicit) threads when you
already
> have several apps (the same as threads only they each have their own
memory
> section)?
> 
> Arnold

Or... if you don't want to waste.. I mean use up.. a bunch of RAM to
store the data...

When you create the socket, you can have it output directly to a file,
and then simply watch for the finished signal...

Scott




More information about the Qt-interest-old mailing list