Reading from SocketChannel

Discussion in 'Java' started by xEM, Apr 27, 2004.

  1. xEM

    xEM Guest

    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 ?


    --
    pozdr.;)
    ~xEM
     
    xEM, Apr 27, 2004
    #1
    1. Advertising

  2. xEM

    xarax Guest

    "xEM" <> wrote in message news:slrnc8t7b1.nva.me@192.168.1.5...
    > 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?
     
    xarax, Apr 27, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fritz Bayer
    Replies:
    16
    Views:
    10,890
    Esmond Pitt
    Jul 27, 2004
  2. ATC
    Replies:
    3
    Views:
    3,357
    Steve Horsley
    Sep 11, 2004
  3. Fritz Bayer
    Replies:
    3
    Views:
    868
    Esmond Pitt
    Nov 14, 2004
  4. Fritz Bayer
    Replies:
    1
    Views:
    1,267
    Gordon Beaton
    Dec 8, 2004
  5. yarivvv
    Replies:
    1
    Views:
    3,077
    Esmond Pitt
    Jul 2, 2005
Loading...

Share This Page