Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-03-2009, 10:23 AM
Member
 
Join Date: Jul 2009
Posts: 1
Rep Power: 0
dfens is on a distinguished road
Default 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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-03-2009, 11:27 AM
Senior Member
 
Join Date: Apr 2009
Posts: 944
Rep Power: 1
Tolls is on a distinguished road
Default
Originally Posted by dfens View Post
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
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.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Creating an auto-expanding JTextArea Singing Boyo New To Java 12 06-10-2009 02:31 AM
[SOLVED] JList Expanding when not all contents visible Singing Boyo New To Java 8 06-01-2009 06:29 AM
[SOLVED] Prevent JTextField from Expanding Within JFrame Singing Boyo New To Java 5 05-15-2009 03:00 AM
[SOLVED] Coordinates container --> in parent container. Cleite AWT / Swing 3 04-22-2009 12:01 AM
Collapsing/Expanding() All nodes in a TreeMenu using javascript Hadley JavaServer Pages (JSP) and JSTL 2 01-31-2009 12:18 AM


All times are GMT +2. The time now is 05:00 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org