Hi Joshua,

2006/1/23, joshua portway <joshlists@stain.org>:
One thing I'm not sure I've understood - In your PacketisingFilter implementation, it looks as if the encoder will still be having to split the message data into buffer size chunks before sending it "down the pipe" to the Packetizing filter which seems to be just adding the header to each buffer. It would seem cleaner for the encoder to just create the encoded message as one big ByteBuffer and the PacketisingFilter to split this up into packets and add the header to each packet.  If I did try to do all the packetizing in the filter, though, I'm still not sure how I would cause a "flush" downstream from the filter to actually write the header and data to the network as a single packet. Also, if I did write the IO filter like this, and there's a method to cause a "flush", does the method block until the data has actually been sent, or am I still going to have to deal with the problem of not being able to slice the buffer ?

Actually, there's no guarentee that one write makes one packet nor that 2+ writes make 2+ packets in TCP/IP.  nextFilter.filterWrite() will signal the socket I/O processor thread to write the data you passed.  But it's not a blocking operation.  It's asynchronous.  I guess you'd better just program your encoder to flush exactly one buffer per message.  Did I understand your problem correctly?

what we call human nature is actually human habit
PGP Key ID: 0x854B996C