Please explain this code

PavanRam

PavanRam

@pavanram-zvmHrU Oct 23, 2024
public String getUserID(String usernmae, String password) {
        String flag = "";
        try {
            if (true) {
                socket = new Socket("localhost", 1111);
                dos = new DataOutputStream(socket.getOutputStream());
                dos.writeUTF("SignIn");
                dos.writeUTF(username);
                dos.writeUTF(password);
                dis = new DataInputStream(socket.getInputStream());
                response = dis.readUTF();
                String[] res_arr = response.split("#");
                if (res_arr[0].equalsIgnoreCase("record")) {
                    flag = "success";
                    userid = Integer.parseInt(res_arr[1]);
                    port = Integer.parseInt(res_arr[2]);
                    secretkey = res_arr[3];
                } else {
                    flag = "failure";
                        }
                      }
            }
} 

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • avii

    avii

    @avii-TGGs8o Apr 11, 2014

    Looks like Java to me, is it? Waht problem you are trying to solve? how about providing some context instead of just copy-pasta