I'm having some trouble with sockets not communicating properly. I wrote out some example code to try to target the problem but it's only confused me further.
I wrote two example classes, TestServer and TestClient.
My TestServer contains:
BufferedReader in = new BufferedReader(newand my TestClient contains:InputStreamReader(ns.getInputStream())); while (true) { System.out.println((in.readLine())); }
then it works fine, constantly outputting ss.BufferedWriter out = new BufferedWriter(new OutputStreamWriter(s.getOutputStream())); BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); while (true) { out.write("ss\n"); }
But if TestClient is as follows:
Then the Server doesn't receive anything.BufferedWriter out = new BufferedWriter(new OutputStreamWriter(s.getOutputStream())); BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); while (true) { String ss = input.readLine(); out.write(ss+"\n"); }
I have no idea what's going on and would greatly appreciate any help.