Download - Cliente

Transcript

7/18/2019 Cliente

http://slidepdf.com/reader/full/cliente-5696772b0a529 1/1

/* * To change this template, choose Tools | Templates * and open the template in the editor. */

package Cliente;import java.io.*;import java.net.*;/** * * @author Administrador */public class Cliente {public static void main(String[] args) {try{Socket sCli = new Socket("localhost", 7777);System.out.println("Cliente ha conectado");String lineaM;do{BufferedReader std = new BufferedReader(new InputStreamReader(System.in));System.out.println("Escribe una linea");String linea = std.readLine();

PrintWriter sal = new PrintWriter(sCli.getOutputStream(), true);BufferedReader ent;ent = new BufferedReader(new InputStreamReader(sCli.getInputStream()));sal.println(linea);lineaM = ent.readLine();System.out.println("Recibido del SERVIDOR= " + lineaM);}while(!lineaM.equals("CHAUFA"));sCli.close();System.out.println("Fin de la Conexion");}catch (UnknownHostException e) { System.out.println("Host desconocido");}catch (IOException e) { System.out.println("Error en cliente");

}}

}