Closed GoogleCodeExporter closed 9 years ago
How the openJDK handles this for TCP sockets:
In java.net.PlainSocketImpl there is a case statement across all known options
to handle validation and preprocessing of the arguments (especially for Boolean
arguments).
Within the native implementation, there is another mapping to the local
(native) socket option values such as those found in sys/socket.h on Linux.
This makes the java implementation independent of the system values.
Unfortunately, junixsocket should also try to be independent from the Java
values.
The Java-side code should convert SocketOptions values to junixsocket values.
The native-side code should convert junixsocket values to native values.
see relevant source from openjdk-6-src-b20-21_jun_2010
(http://openjdk.java.net/projects/jdk6/)
PlainSocketImpl.java (setOption)
PlainSocketImpl.c (socketSetOption)
net_util_md.c (NET_MapSocketOption)
My suggestion for the easiest fix is to implement only the options which users
request. In this case, SO_SNDBUF and SO_RCVBUF. Throw a SocketException for
the others, until someone finds a use case (and test cast) for them.
Original comment by derrick....@gmail.com
on 25 Jun 2010 at 5:17
Changed in SVN trunk. Thanks for pointing this out!
Original comment by ckkohl79
on 20 Jul 2010 at 7:44
Original comment by ckkohl79
on 20 Jul 2010 at 7:44
Based on the diff:
The change was to map from the Java values to the native values by matching
hard-coded numeric values (which correspond to the current Java values) and
returning the values of SO_*.
This has the very unlikely failure case of Java changing the value of their
socket option flags.
I appreciate the prompt fix.
Original comment by derrick....@gmail.com
on 20 Jul 2010 at 8:18
Thanks, Derrick.
I am pretty sure the Socket option flags will not change, as SocketOptions is
part of the public Java API -- it would definitely break more than just
junixsocket. Moreover, the numeric values correspond more or less to BSD's
socket options (at least this is valid for OS X), so I guess they were never
designed arbitrarily.
Best,
Christian
Original comment by ckkohl79
on 21 Jul 2010 at 8:30
Original issue reported on code.google.com by
clint.wo...@gmail.com
on 7 May 2010 at 10:18