Reputation: 1383
I wrote small TCP chat client and server. At start running on localhost, and now i moved it to external host. Personally it works alright because i have my firewall disabled, however on another machine it fails getting IOException (at creating Socket). Tried adding port I'm using 9764 to inbound and outbound rules, later disabling firewall at all and it still didn't work getting same IOException. Any thoughts?
Error log: http://pastebin.com/zEbFbX4Y Client code: https://github.com/karosas/Simple-tcp-chat-client
Exception is catched here:
try {
client = new ChatClient();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
JOptionPane.showMessageDialog(that, "Unknown host exception");
} catch (IOException e) {
JOptionPane.showMessageDialog(that, "IOException");
e.printStackTrace();
}
which leads to ChatClient ->
public ChatClient() throws UnknownHostException, IOException {
server = new Socket(host,port);
out = new PrintWriter(server.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(
server.getInputStream()));
stdIn = new BufferedReader(new InputStreamReader(System.in));
sc = new ServerConn(server);
}
And it leads to ServerConn
private BufferedReader in = null;
public ServerConn(Socket server) throws IOException {
in = new BufferedReader(new InputStreamReader(
server.getInputStream()));
}
public void run() {
String msg;
try {
while((msg = in.readLine()) != null) {
System.out.println(msg);
}
} catch(IOException e ) {
System.err.println(e);
}
}
Thanks for anything.
Upvotes: 0
Views: 482
Reputation:
What is happening is that on localhost the connection doesn't need permission to travel through your internet router's firewall but when it connects to a different internet router that router can reject you from the server if it doesn't whitelist that port so you need to go onto the internet router's NetBIOS (The internet router of the server) and then white-list the ports, usually under:
ADVANCED > NAT > VIRTUAL SERVERS/PORT FORWARDING.
For more info on how to do this read the internet routers manual.
EDIT: What you are doing is trying to connect to a 127.*..** adress meaning it doesn't even go on your network. on server computer rightclick your task bar select task manager go to perforamce tab and select wifi then find the IpV4 address and use that instead of 127.7.13.129
Upvotes: 1