a socket impl question?

Sand Stone sand.m.stone at gmail.com
Sun Jan 13 01:46:23 PST 2013


Thanks for the quick reply, Chris.

Some clarification. Currently I am trying to set non std socket options at
a per Socket instance basis without going through JNI code.  And I take the
statement on Linux back, one could not pass down unknown option value down
at the socket fd level either (the exceptions are different between Windows
and Linux).

Take a specific case, Windows added fast path in the loopback path:

http://blogs.technet.com/b/wincat/archive/2012/12/05/fast-tcp-loopback-performance-and-low-latency-with-windows-server-2012-tcp-loopback-fast-path.aspx
One could see in the article that .NET/CLR supports custom option flags.
Also note that the setting has to be done prior to any actual binding.

A couple of questions:
   1. Is there a plan to support this new ioctl flag for Windows? This will
improve (by 4x) many existing Java based solutions doing LRPC on Windows.
   2. Or provide a code path to allow framework builders to set OS specific
custom socket options? This could be a general mechanism without JDK
changes.
   3. Ideally getting solutions for one of the above backed ported to JDK6
and JDK7.

Doing a custom JNI is a viable option (though one has to trick the current
JDK7 code to create a "fd" without the actual binding, because just "new
Socket()" does not materialize a "fd" until later). It's a pain to
distribute and maintain the native code plus related reflection code.


On Sun, Jan 13, 2013 at 12:22 AM, Chris Hegarty <chris.hegarty at oracle.com>wrote:

> On 12/01/2013 23:20, Sand Stone wrote:
>
>> Hi, JDK devs.
>>
>> Is there a reason the impl not there below?
>>
>
> This is a bug, fixed in jdk8, 7107020: "java.net.PlainSocketImpl.**socketSetOption()
> calls itself"
>
> This bug did not create a much of a problem since setOption() is usually
> called for setting socket options.
>
>
>  jdk/src/windows/classes/java/**net/PlainSocketImpl.java
>>
>>      public void setOption(int opt, Object val) throws SocketException {
>>          setOption(opt, val);   // Why not impl.setOption(opt, val);?
>>      }
>>
>>      public Object getOption(int opt) throws SocketException {
>>          return impl.getOption(opt);
>>      }
>>
>> More generally, is there a general way to pass a non
>> StandardSocketOptions option
>> the down to the socket fd without having to go through the JNI path on
>> Windows?
>>
>
> Not that I am aware of.
>
>
>  Note that on Linux at least the option can be passed directly to the
>> built-in C native path.
>>
>
> Sorry, I don't get this.
>
> -Chris.
>
>
>> Thanks much!
>>
>



More information about the jdk7u-dev mailing list