Client:
Server:public static void updateTest(){ try{ Socket clientUpdate = new Socket(host, 1026); BufferedReader in = new BufferedReader(new InputStreamReader(clientUpdate.getInputStream())); DataOutputStream out = new DataOutputStream(clientUpdate.getOutputStream()); out.writeBytes(Version); //Client those not write out Version to server when I add this //System.out.println(in.readLine()); clientUpdate.close(); }catch(Exception e){ System.out.println(e); System.out.println("Error: Test.updateTest()"); } }
public static void update(){ try{ Socket connectUpdate = updateSocket.accept(); BufferedReader in = new BufferedReader(new InputStreamReader(connectUpdate.getInputStream())); DataOutputStream out = new DataOutputStream(connectUpdate.getOutputStream()); String Data = in.readLine(); System.out.println(Data); /* * When I add this to the code, the server doesnt even receive the string Data from the client if(Data.equals("1.0.0.0")){ out.writeBytes("up to date"); }else{ out.writeBytes("Updating"); } */ connectUpdate.close(); }catch(Exception e){ System.out.println(e); System.out.println("Error: update()"); } }
I have tried so many ways to fix this, like closing the in and outs at different times. I even tried using PrintWriter. I hav no clue why the server wont write back to the client.
--- Update ---
Please dont laugh at me, I fixed it, the shame.