package enterpriseserver.socket;

import java.io.IOException;
import java.net.ServerSocket;



public class Servidor extends Thread {

    protected int puerto_socket;
    private ServerSocket serverSocket = null;
    boolean listening = true;

    public Servidor(int puerto) {
        this.puerto_socket = puerto;
        System.out.println("Iniciando Servidor en puerto: " + puerto_socket);
    }

    public void run() {
        try {
            serverSocket = new ServerSocket(this.puerto_socket);

            while (listening) {
                new ServidorThread(serverSocket.accept()).start();
            }
            serverSocket.close();

        } catch (IOException e) {
            System.out.println("No Se puede Escuchar el puerto :" + puerto_socket);
        }
    }
}
