File tree 3 files changed +19
-17
lines changed
3 files changed +19
-17
lines changed Original file line number Diff line number Diff line change 9
9
public class ClientClass {
10
10
11
11
public static void main (String [] args ) throws Exception {
12
+
12
13
Socket s = null ;
13
14
14
15
PrintWriter pw = null ;
@@ -26,23 +27,23 @@ public static void main(String[] args) throws Exception {
26
27
27
28
while (true ) {
28
29
System .out .println (" -- input the message -- " );
29
- String msg_to = scan .nextLine ();
30
- pw .println (msg_to );
30
+ String msgTo = scan .nextLine ();
31
+
32
+ pw .println (msgTo );
31
33
pw .flush ();
32
34
33
- if (msg_to .equals ("stop" )) {
35
+ if (msgTo .equals ("stop" )) {
34
36
System .out .println (" -- success to be disconnected with server -- " );
35
37
break ;
38
+ } else {
39
+ String msgFrom = br .readLine ();
40
+ System .out .println ("msg: " + msgFrom );
36
41
}
37
-
38
- String msg_from = br .readLine ();
39
- System .out .println ("msg: " + msg_from );
40
-
41
42
}
42
43
43
- scan .close ();
44
44
s .close ();
45
-
45
+ pw .close ();
46
+ br .close ();
47
+ scan .close ();
46
48
}
47
-
48
49
}
Original file line number Diff line number Diff line change 7
7
public class MainClass {
8
8
9
9
public static void main (String [] args ) throws IOException {
10
+
10
11
/*
11
12
ServerSocket ss = null;
12
13
Socket s = null;
@@ -31,5 +32,4 @@ public static void main(String[] args) throws IOException {
31
32
Gender gender = Gender .LESBIAN ;
32
33
System .out .println (gender .convertKorean ());
33
34
}
34
-
35
35
}
Original file line number Diff line number Diff line change 9
9
public class ServerClass {
10
10
11
11
public static void main (String [] args ) throws Exception {
12
+
12
13
ServerSocket ss = null ;
13
14
Socket s = null ;
14
15
@@ -27,19 +28,19 @@ public static void main(String[] args) throws Exception{
27
28
28
29
while (true ) {
29
30
String msg = br .readLine ();
30
- System .out .println ("msg: " + msg );
31
31
32
32
if (msg .equals ("stop" )) {
33
33
System .out .println (" -- the client stops the dialogue -- " );
34
34
break ;
35
+ } else {
36
+ System .out .println ("msg: " + msg );
37
+ pw .println (" -- success to send the message to client -- " );
38
+ pw .flush ();
35
39
}
36
-
37
- pw .println (" -- success to send the message to client -- " );
38
- pw .flush ();
39
40
}
40
41
41
42
ss .close ();
42
-
43
+ pw .close ();
44
+ br .close ();
43
45
}
44
-
45
46
}
You can’t perform that action at this time.
0 commit comments