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

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

/**
 *
 * @author Jose
 */
public class ServeClient extends Thread {

    private Socket incoming;

    public ServeClient(Socket s) {
        incoming = s;
    }

    @Override
    public void run() {

        try {
            BufferedReader in = new BufferedReader(new InputStreamReader(incoming.getInputStream()));
            PrintWriter out = new PrintWriter(incoming.getOutputStream(), true);

            //out.println("Hello! Enter BYE to exit.");
            
            String str = in.readLine();
            out.print("(Echo desde Elo330) " + str);
            /*
            boolean done = false;
            while (!done) {
                String str = in.readLine();
                if (str == null) {
                    done = true;
                } else {
                    out.println("Echo " + str);

                    if (str.trim().equals("BYE")) {
                        done = true;
                    }
                }
            }*/
            incoming.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
