Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2006

Tip: Looking for answers? Try searching our database.

buffer problems

Thread view: 
Andersen - 24 Jan 2006 12:19 GMT
I am asynchronously reading into a ByteBuffer, and I then pick things
out from the buffer. I have a problem with the ByteBuffer abstraction.
Lets say the size of the ByteBuffer is 1000 bytes, and I read 800 bytes
from a socket into the ByteBuffer. I then process it, and write the
first 500 into some other place (because the 500 bytes represent some
object). Now I have 300 bytes of data in the ByteBuffer starting at
position 500 and ending at position 800. Lets say I read on the socket
into the buffer again, and say 400 bytes are ready in the Socket, but if
I read the 400 bytes into the buffer, I overflow the buffer. Yet, I am
only using 300 bytes of the buffer.

Is there a solution to this problem?
Andersen - 24 Jan 2006 12:22 GMT
Oh compact() seems to do the trick! :-)

> I am asynchronously reading into a ByteBuffer, and I then pick things
> out from the buffer. I have a problem with the ByteBuffer abstraction.
[quoted text clipped - 8 lines]
>
> Is there a solution to this problem?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.