[Top][All Lists]

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

[Help-smalltalk] ZLib streams

From: Robin Redeker
Subject: [Help-smalltalk] ZLib streams
Date: Wed, 22 Aug 2007 23:37:53 +0200
User-agent: Mutt/1.5.11+cvs20060403


I'm sorry to disturb you further, but I found something weird
while trying what we discussed:

   Eval [
      PackageLoader fileInPackage: #TCP.
      PackageLoader fileInPackage: #ZLib.
   Eval [
      |zr zw sock|
      sock := TCP.Socket remote: 'localhost' port: 12324.

      zw := RawDeflateStream on: sock.
      zr := RawInflateStream on: sock.

      zw nextPutAll: 'TESTABC'; syncFlush.

      [sock atEnd not] whileTrue: [
         | hunk |
         hunk := zr nextHunk.
         'hunk!' displayNl.
         hunk inspect.

I tested this with socat like this:

   socat TCP4-LISTEN:12324,reuseaddr PIPE

The problem is that this line blocks/hangs:

   zr := RawInflateStream on: sock.

It blocks because RawInflateStream>>#on: calls ZlibReadStream>>#fillBuffer
a few method calls down the stack. And fillBuffer actually does
call nextHunk to wait for data to arrive on the line.

If I rearrange the lines btw.:

      zw nextPutAll: 'TESTABC'; syncFlush.
      zr := RawInflateStream on: sock.

Then everything seems to be fine (because there is data for nextHunk).

Would it be possible to prevent the call to fillBuffer to not have
a blocking RawInflateStream creation and only have it block when _I_
call RawInflateStream>>#nextHunk?



reply via email to

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