@@ -0,0 +1,2994 @@
+package transfertcp;%0A%0Aimport java.awt.Color;%0Aimport java.io.DataInputStream;%0Aimport java.io.DataOutputStream;%0Aimport java.io.IOException;%0Aimport java.net.Socket;%0Aimport java.util.StringTokenizer;%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;%0A%0A/**%0A *%0A * @author JoseCaceres%0A */%0Apublic class Comunicacion implements Runnable%7B%0A    private Socket socket;%0A    private DataOutputStream salida;%0A    private DataInputStream entrada;%0A    private Thread hilo;%0A    private Cliente cliente;%0A    private boolean running, conectado;%0A    %0A    public Comunicacion(Cliente cliente)%7B%0A        running = true;%0A        conectado = false;%0A        this.cliente = cliente;%0A        hilo = new Thread(this);%0A        hilo.setPriority(Thread.MAX_PRIORITY);%0A        hilo.start();%0A    %7D%0A%0A    public Socket getSocket()%7B%0A        return socket;%0A    %7D%0A%0A    public void setRunning(boolean running) %7B%0A        this.running = running;%0A    %7D%0A%0A    @Override%0A    public void run() %7B%0A        while(!conectado) %7B%0A        try %7B%0A            socket = new Socket(%22localhost%22, 5000); %0A            salida=new  DataOutputStream(socket.getOutputStream());%0A            entrada=new  DataInputStream(socket.getInputStream());%0A            conectado = true;%0A            cliente.getConexion().setText(%22conectado al servidor%22);%0A            cliente.getConexion().setForeground(Color.GREEN);%0A        %7D catch (IOException ex) %7B%7D%0A        %7D%0A        write();%0A        while(running)%7B%0A            try %7B%0A                read();%0A            %7D catch (IOException ex) %7B%0A                Logger.getLogger(Comunicacion.class.getName()).log(Level.SEVERE, null, ex);%0A            %7D%0A        %7D%0A       %0A        try %7B%0A            socket.close();%0A        %7D catch (IOException ex) %7B%0A            Logger.getLogger(Comunicacion.class.getName()).log(Level.SEVERE, null, ex);%0A        %7D  %0A    %7D%0A%0A    public DataOutputStream getSalida() %7B%0A        return salida;%0A    %7D%0A%0A    public DataInputStream getEntrada() %7B%0A        return entrada;%0A    %7D%0A%0A    public boolean isRunning() %7B%0A        return running;%0A    %7D%0A    %0A    public void read() throws IOException %7B%0A        String cadena = entrada.readUTF();%0A        if(cadena != null) %7B  %0A           StringTokenizer token = new StringTokenizer(cadena, %22****%22);%0A           String tipo = token.nextToken();%0A           if(tipo.compareTo(%22AA%22) == 0)%0A               this.update(token);%0A        %7D%0A    %7D%0A    %0A    public void update(StringTokenizer token) %7B%0A        int pos = Integer.parseInt(token.nextToken());%0A        int tipo = Integer.parseInt(token.nextToken());%0A        String archivo = token.nextToken();%0A        int length = Integer.parseInt(token.nextToken());%0A        int agregar = Integer.parseInt(token.nextToken());%0A        cliente.actualizarNodoRecurso(archivo, length, tipo, agregar);%0A    %7D%0A    %0A    public void write() %7B%0A        try %7B%0A            salida.writeUTF(%22AA%22);%0A        %7D catch (IOException ex) %7B%0A            Logger.getLogger(Comunicacion.class.getName()).log(Level.SEVERE, null, ex);%0A        %7D%0A    %7D   %0A%7D%0A%0A%0A

Create Comunicacion.java