users@grizzly.java.net

Re: who can help me?how a server base grizzly receive 2MB data from client

From: Peter Murray <peter.murray_at_FXALL.com>
Date: Thu, 31 Jan 2008 07:49:41 -0500

I was going to say my but I am glad I did not since my assumptions
were wrong now that I see
all the experts have answered.

Is your client a Java POJO? Would you mind sharing it?

I have yet to make any real progress on getting a POJO client to talk
to the Server side.
( Currently I only get time on the train to work on it :( )

I do not know if it matters for your problem, but I do not see any
flush in your code.
Does Comet do this automatically? The other examples seem to
explicitly call it.


Peter


On Jan 29, 2008, at 10:41 PM, windshome wrote:

>
> I write a server base grizzly,I write a client which send data to
> server and
> receive response from server. I send 50 bytes data and 2k data to
> server
> ok,but when I send 20K and 2MB data,server no response.
> I view the code of grizzly,find the ByteBuffer of a workthread
> capity is
> 8192,then I modify it to 81920,then 20k data can receive by server.
>
> If my Server set the init size of ByteBuffer is 81920,I think it
> would use
> to much memory,who can tell me some method,will dynamic just the
> buffer,can
> receive some bytes data ,or some MB data?
>
>
>
> My Server's protocol parser code :
>
>
> final ProtocolFilter parserProtocolFilter = new
> ParserProtocolFilter() {
> public ProtocolParser newProtocolParser() {
> return new ProtocolParser() {
> private boolean isExpectingMoreData = false;
> private ByteBuffer byteBuffer;
> private Request message;
>
> public boolean hasMoreBytesToParse() {
> return false;
> }
>
> public boolean isExpectingMoreData() {
> return isExpectingMoreData;
> }
>
> public Object getNextMessage() {
> return message;
> }
>
> public boolean hasNextMessage() {
>
>
> ByteBuffer dup = byteBuffer.duplicate();
> System.out.println( "byteBuffer.position2()=" +
> byteBuffer.position() );
> if (byteBuffer.position() == 0){
> System.out.println("byteBuffer.position()
> ==
> 0");
> isExpectingMoreData = true;
> return false;
> }
> dup.flip();
>
>
> if( dup.remaining()< 4 ){
> isExpectingMoreData = true;
> return false;
> }
>
> byte[] bs = new byte[4];
> dup.get(bs);
> int len= (bs[0] << 24) + (bs[1] << 16) +
> (bs[2] <<
> 8) + (bs[3] << 0);
>
> if( dup.remaining() < len ){
> isExpectingMoreData = true;
> return false;
> }
> byte[] data = new byte[len];
> dup.get( data );
>
> try {
> message = new ByteRequest(data);
> } catch (Exception e) {
> e.printStackTrace();
> message=null;
> return false;
> }
> return true;
>
> }
>
> public void startBuffer(ByteBuffer bb) {
> byteBuffer = bb;
> }
>
> public boolean releaseBuffer() {
> byteBuffer = null;
> message = null;
> return false;
> }
>
> };
> }
> };
>
>
>
>
>
>
>
> --
> View this message in context: http://www.nabble.com/who-can-help-me-how-a-server-base-grizzly-receive-2MB-data-from-client-tp15174927p15174927.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>

Peter Murray
Manager,
Relationship Trading

peter.murray_at_fxall.com
Office: +1 646-268-9916
Cell : +1 914-414-3727
AIM : retepmurray