help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] ZLib Z_SYNC_FLUSH/Z_FULL_FLUSH


From: Robin Redeker
Subject: Re: [Help-smalltalk] ZLib Z_SYNC_FLUSH/Z_FULL_FLUSH
Date: Wed, 22 Aug 2007 16:42:58 +0200
User-agent: Mutt/1.5.11+cvs20060403

On Wed, Aug 22, 2007 at 03:58:30PM +0200, Paolo Bonzini wrote:
> 
> >Yea, I'm currently writing some kind of network server where I would
> >like to use Zlib to optimize the overhead a bit. I'm currently trying
> >to figure out how streams are supposed to work at all and wrote some
> >code some hours ago to init a compression handshake in the protocol
> >I've implemented. Now all I need to figure out is how to plug the
> >compression streams on that already existing TCP Stream :-)
> 
> The "testSyncFlush" test I introduced in zlibtests.st can help.  The 
> code would go something like this (just to give an idea):
> 
> initialize
>     yourTCPSocket := blahblah.
>     deflatedData := RawDeflateWriteStream on: yourTCPSocket

Would something like this also work:

initialize
   tcpSocket := etc.
   deflateStream := RawDeflateWriteStream on: tcpSocket.
   inflateStream := RawInflateStream on: tcpSocket.

nextPutPacket: uncData
   deflateStream nextPutAll: uncData; syncFlush.

nextPacket
   | uncData |
   uncData := inflateStream nextHunk.
   uncBuffer addData: uncData.
   ...

That would be mostmy my usage: having the tcp stream completly
compressed and mostly replacing the tcpSocket by inflate/deflate
streams.

The actual read-loop in my program looks like this:

     [[inputStream atEnd not] whileTrue: [self handleData: inputStream 
nextHunk]]

I would then after the compression-handshake replace inputStream (which is a 
tcp socket
before the handshake) with an inflate stream.

(I'll be digging into this more thise evening)



Robin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]