On Thu, 24 Jun 2010 12:27:30 +0200, Emmanuel Lecharny
<[email protected]>
wrote:
>> But where? I checked out the complete source (1hr ago) and had a look
>> into
>>    
> 
> You *have* to fix the value if you want it to be something that fits 
> your need. If not, the socket buffer size won't be set, as we check that

> the config value has changed before setting it.

That's exactly my expectation, yes.

Maybe I post a better code sample.

Test #1
--code--
NioSocketAcceptor acceptor = new NioSocketAcceptor();
System.out.println("recv buffer size =
"+acceptor.getSessionConfig().getReceiveBufferSize());
// ... setup filter chain ...
// ... setup handlers ...
acceptor.bind(new InetSocketAddress(55555));
System.out.println("recv buffer size =
"+acceptor.getSessionConfig().getReceiveBufferSize());
--/code--

--output--
recv buffer size = -1
recv buffer size = -1
--/output--

--> It's not possible to read the buffer's size before or after the
bind(). I always get -1 ..

Test #2
--code--
NioSocketAcceptor acceptor = new NioSocketAcceptor();
System.out.println("recv buffer size =
"+acceptor.getSessionConfig().getReceiveBufferSize());
acceptor.getSessionConfig().setReceiveBufferSize(1);
System.out.println("changed recv buffer size =
"+acceptor.getSessionConfig().getReceiveBufferSize());
// ... setup filter chain ...
// ... setup handlers ...
acceptor.bind(new InetSocketAddress(55555));
System.out.println("recv buffer size =
"+acceptor.getSessionConfig().getReceiveBufferSize());
--/code--

--output--
recv buffer size = -1
changed recv buffer size = 1
recv buffer size = 1
--/output--

--> Output is still nto correct. I always get -1 before I set an value. I
set the buffer size to 1, so that the data transfer from client to server
should be horrible slow. But it isn't. So the change I made on buffer size
is not passed to the socket, but only to the session config object.

Test #3
--code--
NioSocketAcceptor acceptor = new NioSocketAcceptor();
System.out.println("recv buffer size =
"+acceptor.getSessionConfig().getReceiveBufferSize());
// ... setup filter chain ...
// ... setup handlers ...
acceptor.bind(new InetSocketAddress(55555));
System.out.println("recv buffer size =
"+acceptor.getSessionConfig().getReceiveBufferSize());
acceptor.getSessionConfig().setReceiveBufferSize(1);
System.out.println("changed recv buffer size =
"+acceptor.getSessionConfig().getReceiveBufferSize());
--/code--

--output--
recv buffer size = -1
recv buffer size = -1
changed recv buffer size = 1
--/output--

--> Same effect as result from Test #2

It seems that I can do what I want, but the socket does not get my
changes. I debugged all tests, but did not find any call that actually sets
my buffer size on the socket.

So, did I miss something or is the fix you made really not complete?

br,
Alex



> 
> In any case, if the -1 value were to be used to set the socket buffer 
> size, an IllegalParameterException would have been thrown.
> 
> So here are the use cases :
> - you don't set any value : the OS value will be used as we don't apply 
> the -1 value
> - you have set a value in the SessionConfig : it will be used when the 
> session is created
> 
> What you can do is to get the underlying socket buffers size and print 
> them out to see that the OS value is in fact used in your tests.

Reply via email to