public class Cliente { Socket socket; public void ejecutar() { try { socket = new Socket("localhost", 5000); BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream())); PrintWriter pw = new PrintWriter(new OutputStreamWriter(socket.getOutputStream())); String linealeida =""; Scanner sc = new Scanner(System.in); do { pw.println(sc.nextLine()); pw.flush(); linealeida = br.readLine(); System.out.println(linealeida); } while (linealeida.equals("cerrar") == false); sc.close(); br.close(); pw.close(); } catch (IOException e) { System.out.println("Error en el Socket del Cliente: " + e); } } public static void main(String[] args) { (new Cliente()).ejecutar(); } }