Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TCP Socket Creation Failure

 
Alex Kirk
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using the Socket mySock = new Socket("my.ip.add.ress", port#) construct, I'm unable to create a connection on my local machine; I get a "connection refused" error.
At first, I thought this was an OS issue; I run OpenBSD, and they're notoriously paranoid about security. However, the folks at misc@openbsd.org have basically assured me that the OS is not the issue, and they're backed up by the fact that I can call Python to do basically the same thing without any trouble.
I've had it suggested to me that Java is setting up the kernel call wrong, and that's the only plausible thing I can think of -- particularly since I have upgraded my kernel sine I installed my Java compiler (BTW, I run JDK 1.1.8).
Is there any testing I can to do see what the cause of the problem might be? Any ideas as to what might be going wrong?
Thanks,
Alex Kirk
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's seems to me that either your socket address or port are wrong, the server you're trying to connect to isn't listening for connections, or (and this may be the culpret) the JVM permission aren't set to allow connections. To do this last one, create a text file (let's call it myPermissions)in the same directory as you server (I assume you're using a custom java server) containing this
grant {
permission java.net.SocketPermission "*:1024-65535",
"connect,accept";
permission java.net.SocketPermission "*:80", "connect";
};
Now, start the server by including the -D flag to set the security policy for the server.
java -Djava.security.policy=MyPermissions MyServer
This may solve you problem.
Sean
 
Alex Kirk
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except for the fact that I'm not using a custom server, or anything like that. It's just a filesharing client program, nothing special. You can see my source at:
www.schnarff.com/gnutonic/
The file with the call in question is networkConnect.java.
Thanks for actually replying.
Alex
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic