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
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk