• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

TCP Socket Creation Failure

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 [email protected] 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
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic