Results 1 to 2 of 2
- 07-03-2009, 09:23 AM #1
Member
- Join Date
- Jul 2009
- Posts
- 1
- Rep Power
- 0
dynamically expanding byte container?
Hello everyone,
Imagine this scenario:
You have a message which you receive as blocks of bytes. The total size of the message is unknown from the start but is indicated to you in the last block (imagine with EOF).
I cannot use a byte array of fixed size because the max size is unknown from the start. I need something that can EXPAND DYNAMICALLY.
There is something called ByteBuffer that could probably be suited for this. Any other ideas/recommendations?
Also...imagine these messages have an ID attached to them, and that many are sent simultaneously, that is: they come intermigled (mixed). What would you do to keep them separated?
Thanks for any help you can provide!
Alex
- 07-03-2009, 10:27 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
This is off the top of my head, and of course subject to whatever specific requirements you have and what you're actually doing with all this stuff.
Assuming a single message is coming through a single point (ie it isn't split amongst threads), you have an id so you can use a HashMap, or similar, with the id as key, and something to hold the bytes as a value. Add each block to this "something". This something needs to be able to point out when it is finished (ie it has encountered the EOF), so that whatever needs to be done to the bytes can be done, and so it can be removed from the Map, otherwise it'll simply fill up.
As I say above, though, this is off the top of my head, so may be completely rubbish.
Similar Threads
-
[SOLVED] Creating an auto-expanding JTextArea
By Singing Boyo in forum New To JavaReplies: 12Last Post: 06-10-2009, 01:31 AM -
[SOLVED] JList Expanding when not all contents visible
By Singing Boyo in forum New To JavaReplies: 8Last Post: 06-01-2009, 05:29 AM -
[SOLVED] Prevent JTextField from Expanding Within JFrame
By Singing Boyo in forum New To JavaReplies: 5Last Post: 05-15-2009, 02:00 AM -
[SOLVED] Coordinates container --> in parent container.
By Cleite in forum AWT / SwingReplies: 3Last Post: 04-21-2009, 11:01 PM -
Collapsing/Expanding() All nodes in a TreeMenu using javascript
By Hadley in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 01-30-2009, 11:18 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks