Commit ca0737d4 authored by 9731087's avatar 9731087

Second edition: firstEdition + server sends a message too, and Client catches.

parent 06ffa244
...@@ -19,6 +19,14 @@ public class ClientHandler implements Runnable { ...@@ -19,6 +19,14 @@ public class ClientHandler implements Runnable {
//TODO: implement this method //TODO: implement this method
// System.out.println("This is incoming message from Client: "); // System.out.println("This is incoming message from Client: ");
System.out.println(message); System.out.println(message);
PrintWriter printWriter = null;
try {
printWriter = new PrintWriter(new OutputStreamWriter(client.getOutputStream()));
} catch (IOException e) {
e.printStackTrace();
}
printWriter.println(message);
printWriter.flush();
} }
@Override @Override
......
...@@ -17,8 +17,9 @@ public class Network { ...@@ -17,8 +17,9 @@ public class Network {
PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(socket.getOutputStream())); PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
printWriter.println("Hello from " + socket.getLocalSocketAddress()); printWriter.println("Hello from " + socket.getLocalSocketAddress());
printWriter.flush(); printWriter.flush();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
//socket.close(); System.out.println(bufferedReader.readLine());
socket.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment