Java client cannot connect to Server externally

Joined
Jan 21, 2004
Messages
561
This is programming, but I think it's best fit for this forum. I apologize in advance if I'm wrong.

I have a simple Java setup that's supposed to communicate back and fourth between the client and server.

It all works fine on the LAN using localhost or 127.0.0.1 but when I put in my external IP to create a socket for, I get an IO exception. I'm using port 5000, and I did go into my router and forward that port to my computer's local IP.

Any ideas?

Here's the client code if it helps, the server code simply listens on port 5000

PHP:
Socket theSocket = null;
PrintWriter out = null;
BufferedReader in = null;
try {
    theSocket = new Socket("55.5555.555", 5000);
    out = new PrintWriter(kkSocket.getOutputStream(), true);
    in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream()));
 } catch (IOException e) {
System.err.println("Couldn't get I/O for the connection");
System.out.println(e.getMessage());
System.exit(1);
}

output:
PHP:
Couldn't get I/O for the connection
Connection refused: connect

Process completed.
 
Back
Top