Documento 1 No Guardado

  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Documento 1 No Guardado as PDF for free.

More details

  • Words: 111
  • Pages: 1
Archivo: Documento 1 no guardado import java.io.*; import java.net.*; import java.util.*; class IMServer extends Thread { Scanner in; PrintWriter out; static ArrayList pool = new ArrayList(); public IMServer(Socket s) throws IOException { in = new Scanner(s.getInputStream()); out = new PrintWriter(s.getOutputStream(),true); pool.add(out); start(); } public static void main(String args[]) throws IOException { ServerSocket ss = new ServerSocket(7777); while(true) new IMServer(ss.accept()); } public void broadcast(String l ) { for(PrintWriter output : pool) if ( !output.equals(out) ) output.println(l); } public void run() { broadcast("NEW CLIENT"); try { while(true) { String line = in.nextLine(); if (line.equalsIgnoreCase("quit")) break; else broadcast(line); } } catch (Exception e) {} pool.remove(out); out.close(); broadcast("CLIENT GONE"); } }

Página 1 de 1

Related Documents

Documento 1 No Guardado
December 2019 11
Documento 1
October 2019 18
Documento 1
April 2020 4
Documento 1
May 2020 10
Documento-1
June 2020 8