From version 8 onwards FreeBSD supports IP_BINDANY socket option which the man page defines as:
If the IP_BINDANY option is enabled on a SOCK_STREAM, SOCK_DGRAM or a
SOCK_RAW socket, one can bind(2) to any address, even one not bound to
any available network interface in the system. This functionality (in
conjunction with special firewall rules) can be used for implementing a
transparent proxy. The PRIV_NETINET_BINDANY privilege is needed to set
this option.
Is it possible to write a Java program that can use this functionality? I have checked the docs of SocketOptions and it obviously does not list this option. So is there any workaround?
with regards,
raj
It is not possible using a pure Java.
There are a couple of JNA/JNI based libraries for making Posix system calls from a Java program; see this SO question/answer for details:
I don’t know if these are available for Java on FreeBSD.
On further thought, it might be possible to implement this in pure (though necessarily non-portable) Java. It would entail creating subclasses of SocketImpl and/or DatagramSocketImpl and the necessary infrastructure to use them. It would be complicated.