File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes can't connect to server via socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "can Watch "can New topic

can't connect to server via socket

Adam Krupczynski

Joined: Apr 18, 2009
Posts: 5

I'm trying to create client/server application. I wrote both, compile (client is an applet) and run on my localhost and everything worked fine. Unfortunately, when I uploaded my client and server applications on server I can't connect and get IOException here:

where "host" is a string; it contains external IP of my server.

I tried to sign applet but nothing changed. Is it possible that Ubuntu on that server somehow block socket connection? Maybe I have to add something in java.policy file? I've searched on google and this forum, read a lot of threads but I couldn't find solution. What can be wrong with it?

E: Ok, I dig a little deeper and now I'm getting "Network is unreachable: connect". but still I can't find out how to fix it...
Carey Evans
Ranch Hand

Joined: May 27, 2008
Posts: 225

If it was an applet security problem, like with java.policy, I'd expect you to get an AccessControlException. It could be a firewall problem on the server or the client; you could use nmap to see what ports get through, or try opening the connection from a Java application instead of an applet.
Adam Krupczynski

Joined: Apr 18, 2009
Posts: 5
thanks for answer. Nmap said after scan that port which I'm using to connect is filtered. Currently I'm trying to open any port, because standard

iptables -A INPUT -p tcp --dport _myport_ -j ACCEPT

doesn't work. So it seems that it's not a java problem anymore, but if anyone knows simple way to fix it it would be great .
subject: can't connect to server via socket
It's not a secret anymore!