| 1 | import java.io.*; |
| 2 | |
| 3 | |
| 4 | public class Main { |
| 5 | |
| 6 | /** |
| 7 | * Main for testing ClientSimplifie |
| 8 | */ |
| 9 | private static void main1() { |
| 10 | SocketClient client = new SocketClient(); |
| 11 | |
| 12 | try { |
| 13 | client.sendMsg("Line1"); |
| 14 | String msg = client.receiveMsg(); |
| 15 | System.out.println(msg); |
| 16 | } |
| 17 | catch (Exception e) { |
| 18 | System.err.println("Exception: " + e); |
| 19 | } |
| 20 | finally { |
| 21 | client.closeRWIO(); |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | |
| 26 | public static void main (String[] args) { |
| 27 | SocketClient client = new SocketClient(); |
| 28 | |
| 29 | // try { |
| 30 | ThreadClientSend thCS = new ThreadClientSend(client); |
| 31 | //FIXME: Implement a loop based on user input to set dynamically the message to sent. |
| 32 | //for (int i = 0; i < 10; i++) { |
| 33 | // thCS.setMsg("Line" + i); |
| 34 | //} |
| 35 | thCS.setMsg("Line1"); |
| 36 | Thread thS = new Thread(thCS); |
| 37 | Thread thR = new Thread(new ThreadClientReceive(client)); |
| 38 | thS.setName("thS"); |
| 39 | thS.start(); |
| 40 | thR.setName("thR"); |
| 41 | thR.start(); |
| 42 | // } |
| 43 | // catch (Exception e) { |
| 44 | // System.err.println("Exception: " + e); |
| 45 | // } |
| 46 | // finally { |
| 47 | // client.closeRWIO(); |
| 48 | // } |
| 49 | |
| 50 | } |
| 51 | |
| 52 | } |