package com.wallace.demo.socket;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created by Wallace on 2016/11/4.
 */
public class TalkServer {
    private static Logger log = LoggerFactory.getLogger(TalkServer.class);

    public static void main(String args[]) {
        try {
            ServerSocket server = new ServerSocket(9999);
            Socket client = server.accept();
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    client.getInputStream()));
            PrintWriter out = new PrintWriter(client.getOutputStream());

            /**The message from Server*/
            BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));
            String client_msg = in.readLine();
            String response = sin.readLine();
            if (response != null) {
                response = sin.readLine();
            }
            while (client_msg != null || client_msg == "end") {
                System.out.println("[Server] Message from Client: " + client_msg);
                String response_msg;
                if (response == null) {
                    response_msg = "Received an message successfully.";
                } else {
                    response_msg = "Received an message successfully." +
                            "<RESPONSE_MESSAGE>" + response;
                }
                System.out.println("[Server] Send an message to Client: " + response_msg);
                out.println(response_msg);
                out.flush();
                client_msg = in.readLine();
                response = sin.readLine();
            }
            client.close();
        } catch (Exception e) {
            System.out.println("Error:" + e);
        }
    }
}


@@ -231,16 +231,42 @@
 .Socket;
+%0Aimport java.util.Objects;
 %0A%0A/**%0A *
@@ -1118,11 +1118,27 @@
 ull 
-%7C%7C 
+&& !Objects.equals(
 clie
@@ -1147,18 +1147,17 @@
 _msg
- ==
+,
  %22end%22)
+)
  %7B%0A 

update src code