diff --git a/src/ThreadReceiveTCP.java b/src/ThreadReceiveTCP.java index d9b0f37..ff706f5 100644 --- a/src/ThreadReceiveTCP.java +++ b/src/ThreadReceiveTCP.java @@ -30,12 +30,14 @@ public void run(){ try { System.out.println("port ou jessaye d'ecouter : " + client1Socket.getLocalPort()); Socket client2Socket = client1Socket.accept(); - System.out.println("Connexion effective"); + System.out.println("Connexion effective"); PrintWriter writer = new PrintWriter(client2Socket.getOutputStream()); while (client1Socket.isBound()){ - System.out.println("message a envoyer : "); - writer.println(sc.next()); + //System.out.println("message a envoyer : "); + //writer.println(sc.next()); + // writer.println("coucou"); } + writer.println("coucou"); writer.close(); } catch (IOException ex) { Logger.getLogger(ThreadReceiveTCP.class.getName()).log(Level.SEVERE, null, ex); diff --git a/src/ThreadSendTCP.java b/src/ThreadSendTCP.java index c842590..c5deff7 100644 --- a/src/ThreadSendTCP.java +++ b/src/ThreadSendTCP.java @@ -12,7 +12,6 @@ public class ThreadSendTCP extends Thread { private String ip; private int port; - private Socket socket; public ThreadSendTCP(String name, String ip1, int port1){ super(name); @@ -22,6 +21,7 @@ public ThreadSendTCP(String name, String ip1, int port1){ } public void run() { + Socket socket; try { socket = new Socket(ip,port); @@ -30,13 +30,14 @@ public void run() { BufferedReader reader = new BufferedReader(stream); String message = reader.readLine(); System.out.println("le client m'a rep : " + message ); + loopMsg(socket); } catch (IOException ex) { Logger.getLogger(ThreadSendTCP.class.getName()).log(Level.SEVERE, null, ex); } } - public void loopMsg() throws IOException{ + public void loopMsg(Socket socket) throws IOException{ while(true){ InputStreamReader stream = new InputStreamReader(socket.getInputStream()); BufferedReader reader = new BufferedReader(stream);