Reading from SocketChannel

X

xEM

I have ByteBuffer for example:
ByteBuffer bBuffer = ByteBuffer.allocate(1024);

How write data to and read data from SocketChannel that is big lenght
and put it into ByteBuffer that i will process later?

Normally when data fit in bBuffer i make this:

on server side:
---------------
bBuffer.put(data);
bBuffer.flip();
channel.write(bBuffer);

on client side:
---------------
channel.read(bBuffer);
bBuffer.flip();

But when i want to send more than 1024 bytes of data? How can i do?
that Any ideas ?
 
X

xarax

xEM said:
I have ByteBuffer for example:
ByteBuffer bBuffer = ByteBuffer.allocate(1024);

How write data to and read data from SocketChannel that is big lenght
and put it into ByteBuffer that i will process later?

Normally when data fit in bBuffer i make this:

on server side:
---------------
bBuffer.put(data);
bBuffer.flip();
channel.write(bBuffer);

on client side:
---------------
channel.read(bBuffer);
bBuffer.flip();

But when i want to send more than 1024 bytes of data? How can i do?
that Any ideas ?

Ever heard of a loop?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top