class MySocket
def initialize
# …
@i_stream = Zlib::Inflate.new
@o_stream = Zlib::Deflate.new
# …
end
def poll
# …
@inbuf << @i_stream.inflate(@socket.readpartial(4096))
# …
end
def send
# …
@socket.write @o_stream.deflate( p.contents, Zlib::SYNC_FLUSH )
# …
end
# …
end
class MySocket
def initialize
# …
@i_stream = Zlib::Inflate.new
@o_stream = Zlib::Deflate.new
# …
end
def poll
# …
@inbuf << @i_stream.inflate(@socket.readpartial(4096))
# …
end
def send
# …
@socket.write @o_stream.deflate( p.contents, Zlib::SYNC_FLUSH )
# …
end
# …
end
The problem I'm running is purely a lack of understanding of exactly how I'm supposed to generate the correct data for the 'zlib stream.'
Originally, I thought this was as simple as compressing and sending stuff out like:
Apparently I'm going to need to do something more like:
Both ways seem to be a fail for clients to understand.
I'm probably missing something, but any insights on the subject would be appreciated.