Can't connect to my server socket using external IP
Hi I'm very new to Java programming, and I'm learning all the core things I need to understand so that I can make a simple networked game using a command-line server and applet clients. I tried the networking tutorial and it worked perfectly on my machine.
However, it only works if I supply the client with my INTERNAL IP. When I give it my EXTERNAL IP it cannot connect to the server socket. The error thrown is a IOException.
The code:
import java.io.*;
import java.net.*;
publicclass KnockKnockClient{
publicstaticvoid main(String[] args)throws IOException{
Socket kkSocket =null;
PrintWriter out =null;
BufferedReader in =null;
try{
kkSocket =new Socket("192.168.2.3", 4444);
out =new PrintWriter(kkSocket.getOutputStream(),true);
in =new BufferedReader(new InputStreamReader(kkSocket.getInputStream()));
}catch (UnknownHostException e){
System.err.println("Don't know about host.");
System.exit(1);
}catch (IOException e){
System.err.println("Couldn't get I/O for the connection.");
System.exit(1);
}
BufferedReader stdIn =new BufferedReader(new InputStreamReader(System.in));
String fromServer;
String fromUser;
while ((fromServer = in.readLine()) !=null){
System.out.println("Server: " + fromServer);
if (fromServer.equals("Bye."))
break;
fromUser = stdIn.readLine();
if (fromUser !=null){
System.out.println("Client: " + fromUser);
out.println(fromUser);
}
}
out.close();
in.close();
stdIn.close();
kkSocket.close();
}
}
The code works fine with my internal IP (192.168.2.3) but not my external IP (86.3.51.171). Any ideas about how to fix it?

