Socket Option Requiring Custom Implementation

Alan Bateman Alan.Bateman at oracle.com
Wed Oct 13 03:17:17 PDT 2010


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/net-dev/attachments/20101013/5957172c/attachment.html 


More information about the net-dev mailing list