MAC OS 10.5.7 FireWall & Java Socket programing
Hi everyone,
I am fighting for few days with a simple problem in vain.
I am programming a simple java client-server application based on TCP sockets but I do not manage to open any socket at all due to a "connection refused" problem:
In the previous versions of MAC OS X Leopard it was possible to open communication port easily. The latest version of leopard no longer support this functionality. Now you can grant permission only to applications (not to java programs).
I tried the following:
Creating a script that starts my application and uses the firewall setup program to grant permission to that script: Impossible only application can be managed neither script nor JAR files are accepted.
Modifying low level firewall parameters using IPFW: useless the MAC firewall works at a lower level. changing local firewall rules does change anything.
I am thinking about modifying the /library/Java/Home/lib/java.security file but I think that it works only for Applets.
I try to grant permissions to the java executable file using the firewall configuration panel but the problem is still present.
I am sure that lots of programers had this problem.. Anyone have a simple solution ?
Thx for your time.
PS: here a simple code example of what I am doing.
try
{
socket = new Socket(InetAddress.getLocalHost(),port);
}
catch (UnknownHostException e)
{
e.printStackTrace();
}
and the output is:
java.net.ConnectException: Connection refused