[sctp-dev] Socket Options Issue
Alan Bateman
Alan.Bateman at Sun.COM
Thu Jan 14 07:23:09 PST 2010
Bruce Buffam wrote:
>
> Hi Chris,
>
>
>
> I am currently working on integrating the use of SCTP channels into
> Netty, an Open Source networking framework and I encountered an odd
> behaviour in setting/getting SO_RCVBUF or SO_SNDBUF. Typically, I
> have some test code that sets one or both of these options and then
> immediately tries to retrieve the value. If the retrieved value does
> not match the value that was set, the test code throws an exception.
>
FWIW, when you set these socket options then you are providing a "hint"
so you can't assume that the retrieved value will always be exactly the
value that you set.
>
>
>
>
> Here is some example code:
>
>
>
> @SuppressWarnings("restriction")
>
> public void setReceiveBufferSize(int receiveBufferSize) {
>
> // TODO Auto-generated method stub
>
>
>
> try {
>
>
> channel.setOption(SctpStandardSocketOption.SO_RCVBUF, receiveBufferSize);
>
> int temp =
> channel.getOption(SctpStandardSocketOption.SO_RCVBUF);
>
> if (temp != receiveBufferSize)
>
> throw new IOException("SO_RCVBUF not correctly
> set");
>
> } catch (IOException e) {
>
> // TODO Auto-generated catch block
>
> e.printStackTrace();
>
> }
>
> }
>
>
>
> My test case uses odd values like 9753, etc. What I noticed, is that
> when I do the get, it consistently retrieves the value I set,
> multiplied by 2.
>
>
Chris - this sounds like you might be missing the conversion/mapping
that is done by NET_SetSockOpt/NET_GetSocketOpt.
-Alan.
More information about the sctp-dev
mailing list