From: Jérôme Benoit Date: Mon, 12 Mar 2018 22:05:59 +0000 (+0100) Subject: TD2: CRLF -> LF conversion. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b1bd144dcdf623152885186e165a39ddd65afd88;p=TD_SR.git TD2: CRLF -> LF conversion. Signed-off-by: Jérôme Benoit --- diff --git a/TD2/server/EchoServerThreadService.java b/TD2/server/EchoServerThreadService.java index e04d18f..257f15c 100644 --- a/TD2/server/EchoServerThreadService.java +++ b/TD2/server/EchoServerThreadService.java @@ -1,58 +1,58 @@ -import java.net.*; -import java.io.*; -import java.util.*; - -public class EchoServerThreadService implements Runnable { - - private Socket clientSocket; - private ArrayList listWriter; - - EchoServerThreadService(Socket clientSocket) { - System.out.println("Creation d'un thread pour repondre a un client, port " + clientSocket.getPort()); - this.clientSocket = clientSocket; - } - - public void run() { - try { - doService(clientSocket); - clientSocket.close(); - } catch (IOException e) { - System.err.println("IOException : " + e); - e.printStackTrace(); - } - finally { - try { - if (this.clientSocket != null) - this.clientSocket.close(); - } catch (IOException e) { - System.err.println("IOException : " + e); - e.printStackTrace(); - } - } - } - - public void doService(Socket clientSocket) throws IOException { - BufferedReader in; - PrintStream out; - in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); - out = new PrintStream(clientSocket.getOutputStream()); - //listWriter.add(new PrintWriter(clientSocket.getOutputStream())); - boolean end = false; - while (!end) { - String theLine = in.readLine(); - if (theLine.equals(".")) - end = true; // le thread de service doit terminer - out.println(theLine); - } - System.out.println("Fin du thread repondant au client, port " - + clientSocket.getPort()); - } - - public void broadcastMsg(String msg) { - for (int i = 0; i < listWriter.size(); i++) { - listWriter.get(i); - } - - } - -} +import java.net.*; +import java.io.*; +import java.util.*; + +public class EchoServerThreadService implements Runnable { + + private Socket clientSocket; + private ArrayList listWriter; + + EchoServerThreadService(Socket clientSocket) { + System.out.println("Creation d'un thread pour repondre a un client, port " + clientSocket.getPort()); + this.clientSocket = clientSocket; + } + + public void run() { + try { + doService(clientSocket); + clientSocket.close(); + } catch (IOException e) { + System.err.println("IOException : " + e); + e.printStackTrace(); + } + finally { + try { + if (this.clientSocket != null) + this.clientSocket.close(); + } catch (IOException e) { + System.err.println("IOException : " + e); + e.printStackTrace(); + } + } + } + + public void doService(Socket clientSocket) throws IOException { + BufferedReader in; + PrintStream out; + in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); + out = new PrintStream(clientSocket.getOutputStream()); + //listWriter.add(new PrintWriter(clientSocket.getOutputStream())); + boolean end = false; + while (!end) { + String theLine = in.readLine(); + if (theLine.equals(".")) + end = true; // le thread de service doit terminer + out.println(theLine); + } + System.out.println("Fin du thread repondant au client, port " + + clientSocket.getPort()); + } + + public void broadcastMsg(String msg) { + for (int i = 0; i < listWriter.size(); i++) { + listWriter.get(i); + } + + } + +} diff --git a/TD2/server/Main.java b/TD2/server/Main.java index c050448..00d4f9e 100644 --- a/TD2/server/Main.java +++ b/TD2/server/Main.java @@ -1,31 +1,31 @@ -import java.net.*; -import java.io.*; - -public class Main { - public static void main(String[] args) { - ServerSocket listenSocket = null; - try { - listenSocket = new ServerSocket(Integer.parseInt(args[0])); // port - while (true) { // le dispatcher est le thread qui execute main() - Socket clientSocket = listenSocket.accept(); - System.out.println("Connexion de :" + clientSocket.getInetAddress()); - Thread serviceThread = new Thread(new EchoServerThreadService(clientSocket)); - serviceThread.start(); - } - } - catch (Exception e) { - System.err.println("IOException : " + e); - e.printStackTrace(); - } - finally { - try { - if (listenSocket != null) - listenSocket.close(); - } catch (IOException e) { - System.err.println("IOException : " + e); - e.printStackTrace(); - } - } - } - -} +import java.net.*; +import java.io.*; + +public class Main { + public static void main(String[] args) { + ServerSocket listenSocket = null; + try { + listenSocket = new ServerSocket(Integer.parseInt(args[0])); // port + while (true) { // le dispatcher est le thread qui execute main() + Socket clientSocket = listenSocket.accept(); + System.out.println("Connexion de :" + clientSocket.getInetAddress()); + Thread serviceThread = new Thread(new EchoServerThreadService(clientSocket)); + serviceThread.start(); + } + } + catch (Exception e) { + System.err.println("IOException : " + e); + e.printStackTrace(); + } + finally { + try { + if (listenSocket != null) + listenSocket.close(); + } catch (IOException e) { + System.err.println("IOException : " + e); + e.printStackTrace(); + } + } + } + +}