Implementation TCP
This commit is contained in:
parent
8f1c3e6a9b
commit
d9173ea171
1 changed files with 18 additions and 5 deletions
|
@ -177,14 +177,15 @@ public class ChatApp {
|
||||||
|
|
||||||
public static void main (String[] args) throws IOException {
|
public static void main (String[] args) throws IOException {
|
||||||
ChatApp app = new ChatApp(args[0],Integer.parseInt(args[1])) ;
|
ChatApp app = new ChatApp(args[0],Integer.parseInt(args[1])) ;
|
||||||
ExecutorService exec = Executors.newFixedThreadPool(1000);
|
ExecutorService execUDP = Executors.newFixedThreadPool(1000);
|
||||||
exec.submit(new Runner(app));
|
execUDP.submit(new RunnerEcouteUDP(app));
|
||||||
try {
|
try {
|
||||||
app.connexion();
|
app.connexion();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
ExecutorService execTCP = Executors.newFixedThreadPool(1000);
|
||||||
|
execTCP.submit(new RunnerEcouteTCP(app));
|
||||||
try {
|
try {
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -204,15 +205,27 @@ public class ChatApp {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Runner implements Runnable {
|
class RunnerEcouteUDP implements Runnable {
|
||||||
ChatApp app ;
|
ChatApp app ;
|
||||||
public Runner(ChatApp app) {
|
public RunnerEcouteUDP(ChatApp app) {
|
||||||
this.app = app ;
|
this.app = app ;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
UDPEchange.ecouteUDP(app);
|
UDPEchange.ecouteUDP(app);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class RunnerEcouteTCP implements Runnable {
|
||||||
|
ChatApp app ;
|
||||||
|
public RunnerEcouteTCP(ChatApp app) {
|
||||||
|
this.app = app ;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
TCPEchange.ecouteTCP(app);
|
TCPEchange.ecouteTCP(app);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue