• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

TCP Socket Creation Failure

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?
Alex Kirk
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",
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.
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:
The file with the call in question is networkConnect.java.
Thanks for actually replying.
    Bookmark Topic Watch Topic
  • New Topic