| 1 | import java.io.*; |
| 2 | |
| 3 | |
| 4 | public class Main { |
| 5 | |
| 6 | private static void main1() { |
| 7 | SocketClient client = new SocketClient(); |
| 8 | |
| 9 | try { |
| 10 | client.sendMsg("Line 1 Line 2"); |
| 11 | String msg = client.receiveMsg(); |
| 12 | System.out.println(msg); |
| 13 | } |
| 14 | catch (Exception e) { |
| 15 | System.err.println("Exception: " + e); |
| 16 | } |
| 17 | finally { |
| 18 | client.closeRWIO(); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | |
| 23 | public static void main (String[] args) { |
| 24 | |
| 25 | try { |
| 26 | SocketClient client = new SocketClient(); |
| 27 | ThreadClientSend thCS = new ThreadClientSend(client); |
| 28 | thCS.setMsg("Line1 Line2"); |
| 29 | Thread thS = new Thread(thCS); |
| 30 | Thread thR = new Thread(new ThreadClientReceive(client)); |
| 31 | thS.setName("thS"); |
| 32 | thS.start(); |
| 33 | thR.setName("thR"); |
| 34 | thR.start(); |
| 35 | } |
| 36 | catch (Exception e) { |
| 37 | System.err.println("Exception: " + e); |
| 38 | } |
| 39 | finally { |
| 40 | client.closeRWIO(); |
| 41 | } |
| 42 | |
| 43 | } |
| 44 | |
| 45 | } |