Add some trace in error paths.
[TD_SR.git] / TD2 / client / Main.java
index 81a31fb2e99b07607d82e5e10065039b5c2f2249..82fbfc975b563213df2c108f1bc0b23a43711fed 100644 (file)
@@ -4,7 +4,7 @@ import java.io.*;
 public class Main {
 
        /**
-        * Main for testing ClientSimplifie
+        * main for testing ClientSimplifie
         */
        private static void main1() {
                ClientSimplifie client = null;
@@ -25,6 +25,7 @@ public class Main {
                }
                catch (IOException e) {
                        System.err.println("IOException: " + e);
+                       e.printStackTrace();
                }
                finally {
                        client.closeRWIO();
@@ -34,12 +35,16 @@ public class Main {
                                }
                                catch (IOException e) {
                                        System.err.println("IOException: " + e);
+                                       e.printStackTrace();
                                }
                        }
                }
        }
 
-       public static void main (String[] args) {
+       /**
+        * main for text based message broadcasting
+        */
+       public static void main2() {
                SocketClient client = null;
                Thread thS = null;
                Thread thR = null;
@@ -55,6 +60,38 @@ public class Main {
                }
                catch (Exception e) {
                        System.err.println("Exception: " + e);
+                       e.printStackTrace();
+               }
+               finally {
+                       try {
+                               thS.join();
+                               thR.join();
+                       }
+                       catch (InterruptedException e) {
+                               System.err.println("InterruptedException: " + e);
+                               e.printStackTrace();
+                       }
+                       client.closeRWIO();
+               }
+       }
+
+       public static void main(String[] args) {
+               SocketClient client = null;
+               Thread thS = null;
+               Thread thR = null;
+
+               try {
+                       client = new SocketClient(true);
+                       thS = new Thread(new ThreadClientoSend(client));
+                       thR = new Thread(new ThreadClientoReceive(client));
+                       thS.setName("thoS");
+                       thS.start();
+                       thR.setName("thoR");
+                       thR.start();
+               }
+               catch (Exception e) {
+                       System.err.println("Exception: " + e);
+                       e.printStackTrace();
                }
                finally {
                        try {