Commit | Line | Data |
---|---|---|
18eb400b JB |
1 | import java.io.*; |
2 | ||
3 | ||
4 | public class Main { | |
5 | ||
58312685 JB |
6 | /** |
7 | * Main for testing ClientSimplifie | |
8 | */ | |
2c648f75 | 9 | private static void main1() { |
e018d1ec JB |
10 | ClientSimplifie client = null; |
11 | BufferedReader userInput = null; | |
2c648f75 JB |
12 | |
13 | try { | |
e018d1ec JB |
14 | client = new ClientSimplifie(); |
15 | userInput = new BufferedReader(new InputStreamReader(System.in)); | |
16 | boolean end = false; | |
17 | while (!end) { | |
18 | String line = userInput.readLine(); | |
19 | if (line.equals(".")) | |
20 | end = true; | |
21 | client.sendMsg(line); | |
22 | String rline = client.receiveMsg(); | |
23 | System.out.println(rline); | |
24 | } | |
2c648f75 | 25 | } |
e018d1ec JB |
26 | catch (IOException e) { |
27 | System.err.println("IOException: " + e); | |
2c648f75 JB |
28 | } |
29 | finally { | |
30 | client.closeRWIO(); | |
e018d1ec JB |
31 | if (userInput != null) { |
32 | try { | |
33 | userInput.close(); | |
34 | } | |
35 | catch (IOException e) { | |
36 | System.err.println("IOException: " + e); | |
37 | } | |
38 | } | |
2c648f75 JB |
39 | } |
40 | } | |
18eb400b | 41 | |
2c648f75 | 42 | public static void main (String[] args) { |
e018d1ec JB |
43 | SocketClient client = null; |
44 | Thread thS = null; | |
45 | Thread thR = null; | |
18eb400b | 46 | |
e018d1ec JB |
47 | try { |
48 | client = new SocketClient(); | |
49 | thS = new Thread(new ThreadClientSend(client)); | |
50 | thR = new Thread(new ThreadClientReceive(client)); | |
2c648f75 JB |
51 | thS.setName("thS"); |
52 | thS.start(); | |
53 | thR.setName("thR"); | |
54 | thR.start(); | |
e018d1ec JB |
55 | } |
56 | catch (Exception e) { | |
57 | System.err.println("Exception: " + e); | |
58 | } | |
59 | finally { | |
60 | try { | |
61 | thS.join(); | |
62 | thR.join(); | |
63 | } | |
64 | catch (InterruptedException e) { | |
65 | System.err.println("InterruptedException: " + e); | |
66 | e.printStackTrace(); | |
67 | } | |
68 | client.closeRWIO(); | |
69 | } | |
18eb400b JB |
70 | } |
71 | ||
72 | } |