Read the socket API. Specifically the bind method and the connect method that uses four arguments.
This is, of course, something that needs to be done in the code everywhere it is used. There is nothing, AFAIK, that you can do "system" wide, besides maybe writing your own classes to extend Socket and SocketFactory that does this binding automatically.
Thanks masijade.
Currently, I am using createServerSocket(port, backlog, IP).
For which if IP is null then by default it binds to all ip address for that port on that machine.
I was wondering if there is an API which allows bind to only all IPv4 ip address on a host which has both IPv6 and IPv4 IP addresses.
Thanks.