document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public class Servidor {
  2.   public static void main (String [] args ) throws Exception {
  3.     int c = 1;//Inicializamos con un cliente
  4.     double suma = 0;
  5.     ObjectOutputStream oos = null;
  6.     ObjectInputStream  ois = null;
  7.     DataInputStream  dis = null;
  8.     ServerSocket servidor = new ServerSocket(800);
  9.     ServerSocket serv = new ServerSocket(900);
  10.    
  11.     /**
  12.         NUMERO DE CLIENTES QUE EL SERVIDOR PODRA ACEPTAR EN ESTE CASO 2.
  13.     **/    
  14.     while (c<=2) {
  15.       System.out.println("Esperando...");//informativo
  16.  
  17.       Socket socket = servidor.accept();
  18.       System.out.println("Conexion Aceptada Desde Direccion IP : " + socket.getInetAddress());
  19.       if(c==1){
  20.             /**
  21.                 EDITAR LA DIRECCION DEL ARCHIVO DE TEXTO DE ENTRADA
  22.             **/
  23.               File archivo = new File ("C:/GananciasSuc1.txt");
  24.                
  25.               byte [] arreglo  = new byte [(int)archivo.length()];
  26.               FileInputStream entrada = new FileInputStream(archivo);
  27.               BufferedInputStream buf = new BufferedInputStream(entrada);
  28.               buf.read(arreglo,0,arreglo.length);
  29.               OutputStream envio = socket.getOutputStream();
  30.               System.out.println("Enviado...");//informativo
  31.               envio.write(arreglo,0,arreglo.length);
  32.               envio.flush();
  33.               socket.close();
  34.       }
');