Skip to content

Commit

Permalink
tttrr
Browse files Browse the repository at this point in the history
  • Loading branch information
ElyesKhama committed Dec 14, 2017
1 parent 934f986 commit 8ccf889
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/ThreadReceiveTCP.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/ThreadSendTCP.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -22,6 +21,7 @@ public ThreadSendTCP(String name, String ip1, int port1){
}

public void run() {
Socket socket;

try {
socket = new Socket(ip,port);
Expand All @@ -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);
Expand Down

0 comments on commit 8ccf889

Please sign in to comment.