Click to See Complete Forum and Search --> : Setting up a public ServerSocket


Totte_ch
07-02-2009, 07:22 AM
Hey!

I am trying to make a application, that will request data from my personal server. I want the application to open a socket to my public IP with port number 6789.
String host = ""; // my public server IP goes here (removed)
InetAddress group = InetAddress.getByName(host);
Socket socket = new Socket(group, 6789);
Then I set up a PrintWriter and a BufferedReader to send and recieve data.
The server application looks like this:
ServerSocket echoServer = new ServerSocket(6789);
Socket clientSocket = echoServer.accept();For the server application, I also set up a PrintWriter and a BufferedReader to send and recieve data.
My server computer has a private IP (in my local area network) of 192.168.0.20, and my router has that static IP in DMZ, so all incoming connections will be forwarded to my server. That means my server computer it not protected from hacker attacks (router has got firewall), but I've installed a anti-virus program with firewall, so I will not get attacked. I have also opened port 6789 in my router to my server's local IP 192.168.0.20.

This is the error I get:
"Couldn't get I/O for the connection to: xxx.xxx.xxx.xxx"
- Why?
I have other applications, for example Counter-Strike dedicated servers, running on my server, and people outside my network can connect to my server without any problem (those port numbers are also opened).So, I guess the problem not is about my rounter/firewall.

What can I change in my code to make my application work?
I have tested to create a socket to 192.168.0.20 instead of my public IP, and that works...
What am I doing wrong?

I would be very glad if someone could help me with this!
/Totte