Hello David, On Jan 4, 2008 5:10 PM, David M. Lloyd <[EMAIL PROTECTED]> wrote: > I've written an IoFilter that is intended to run over TCP, which > "frames" data into discrete messages in order to make TCP appear to > preserve message boundaries (like UDP) while still retaining the other > advantages of TCP (guaranteed delivery, firewall interoperability, etc).
Isn't this the exact purpose of the ProtocolCodecFilter ? Have you had a look at http://mina.apache.org/tutorial-on-protocolcodecfilter-for-mina-2x.html ? I guess you are looking for a ByteArrayCodecFactory that can encode/decode byte arrays ? Have a look at http://www.mail-archive.com/[email protected]/msg06323.html We could certainly include such a ByteArrayCodecFactory in mina. Trustin, any news on your idea expressed here : http://www.mail-archive.com/[email protected]/msg06290.html ? regards, Maarten > > My filter definitely *works* but it's not very good. It requires that > the message length be prepended to each message. I've got a hack in > such that if the provided outbound buffer has enough space "before" the > current position, it backs up the position and writes the length there. > Otherwise it has to copy the whole buffer. In order to make this work > efficiently, whenever I allocate or flip a buffer I have to "skip" a set > amount of bytes to "make room" for this data. > > On receive, if the incoming buffer contains the whole message, the > filter can just forward a slice of this buffer to the upper layers. > Otherwise it has to copy the data into a new, properly-sized buffer. > > So I'd like to ask your thoughts on the following: > > 1) Support sending multiple buffers in one "go" using gathering-writes > (the message type could be e.g. Collection<IoBuffer> in this case, or > perhaps using a composite buffer [see DIRMINA-489 [1]]). > > 2) Add support to IoBuffer for reserving "space" at the start of the > buffer. The semantics would need some thought here though. For > example, should the buffer capacity include the "reserved" space? > Probably not I guess. Other questions like this would need to be > answered as well. I guess I should open a JIRA ticket for this to > provide a point of reference. > > Anyway, let me know what you guys think about this stuff. > > - DML > > [1] https://issues.apache.org/jira/browse/DIRMINA-489 >
