Implementation TCP

This commit is contained in:
Nabil Moukhlis 2020-12-05 12:40:20 +01:00
parent 8f1c3e6a9b
commit d9173ea171

View file

@ -177,14 +177,15 @@ public class ChatApp {
public static void main (String[] args) throws IOException {
ChatApp app = new ChatApp(args[0],Integer.parseInt(args[1])) ;
ExecutorService exec = Executors.newFixedThreadPool(1000);
exec.submit(new Runner(app));
ExecutorService execUDP = Executors.newFixedThreadPool(1000);
execUDP.submit(new RunnerEcouteUDP(app));
try {
app.connexion();
} catch (IOException e) {
e.printStackTrace();
}
ExecutorService execTCP = Executors.newFixedThreadPool(1000);
execTCP.submit(new RunnerEcouteTCP(app));
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
@ -204,15 +205,27 @@ public class ChatApp {
}
class Runner implements Runnable {
class RunnerEcouteUDP implements Runnable {
ChatApp app ;
public Runner(ChatApp app) {
public RunnerEcouteUDP(ChatApp app) {
this.app = app ;
}
@Override
public void run() {
UDPEchange.ecouteUDP(app);
}
}
class RunnerEcouteTCP implements Runnable {
ChatApp app ;
public RunnerEcouteTCP(ChatApp app) {
this.app = app ;
}
@Override
public void run() {
TCPEchange.ecouteTCP(app);
}