Socket Option Requiring Custom Implementation

2010-10-13 Thread Simon James
I apologise if this is not the appropriate list for this question and welcome 
advice where it would be better posted.

I need to exploit the transparent proxy support in Linux.
However, this requires the setting of a non-standard option (IP_TRANSPARENT) 
before a socket is bound.
To achieve this, it seems to me I have to implement a SocketImplFactory to 
instantiate a custom socket implementation.
And my custom socket implementation cannot extend PlainSocketImpl because it's 
not public.
So I'm faced with having to write a significant amount of code to set on a bit.

Before I go too far down the route, I want to check whether there are any 
openjdk initiatives that might simplify this sort  of activity at some time in 
the future.

Regards

Simon


Re: Socket Option Requiring Custom Implementation

2010-10-13 Thread Alan Bateman

Simon James wrote:
I apologise if this is not the appropriate list for this question and 
welcome advice where it would be better posted.


I need to exploit the transparent proxy support in Linux.
However, this requires the setting of a non-standard option 
(IP_TRANSPARENT) before a socket is bound.
To achieve this, it seems to me I have to implement a 
SocketImplFactory to instantiate a custom socket implementation.
And my custom socket implementation cannot extend PlainSocketImpl 
because it's not public.
So I'm faced with having to write a significant amount of code to set 
on a bit.


Before I go too far down the route, I want to check whether there are 
any openjdk initiatives that might simplify this sort  of activity at 
some time in the future.


Regards

Simon
You might want to look at java.nio.channels.NetworkChannel for ideas. 
You'll see that it defines the setOption/setOption methods and so isn't 
restricted to the standard socket options defined in the javadoc. Some 
day it might be good to retrofit classic 
Socket/ServerSocket/DatagramSocket with methods like these. That way an 
implementation could support additional and platform specific options.


-Alan.