jzlib questions

C

czajnik

Hi !

I'm about to use JZlib for socket connection compression. I have the
following questions about it:

1. Is there any mailing list for JZlib project ? (if so, I'd rather ask
these questions there, of course, but I couldn't find any reference)

2. Do I understand Z_SYNC_FLUSH correctly ? Read below:

Let's say that I plug ZOutputStream directly into ZInputStream, to
create this "useless compressed pipe".

Am I right that Z_SYNC_FLUSH makes it work so I can expect that any
write performed on the out stream will flush everything, so I can get
the same set of bytes ASAP on the output of ZInputStream?

I need zlib-compressed TCP connection, where one side sends arbitrary
sized packets, and expects acknowledge from opposite side after each
packet. Is Z_SYNC_FLUSH what I'm looking for to assure that each
complete packet gets delivered to opposite side so it can be confirmed,
before starting to send the next one (of course we assume that
underlying socket stream is flushed properly) ?

Question below makes sense only if above is true.

3. Is it possible to manually force sync ?
My application calls write() for several small chunks of the packet.
I want it to be synced after last write. ZOutputStream.flush() seems
only to flush underlying stream. Of course I could prepare a packet in
RAM and send it with single call to write(), but I want to avoid
allocating that big buffer.

Am I right that a method similar to ZOutputStream.finish(), but with
Z_SYNC_FLUSH instead of Z_FINISH should solve the problem ?

Currently in my application after each packet I change from Z_NO_FLUSH
to Z_SYNC_FLUSH, send a single dummy byte, ignored by recipient, and
change back to Z_NO_FLUSH. But this seems to be a stuped workaround,
rather than a reliable solution (but it seems to work, anyway).
Best Regards,
Przemyslaw
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top