Skip to content

Commit 5247cc1

Browse files
committed
update the package practice.network.
1 parent 9071508 commit 5247cc1

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

src/practice/network/ClientClass.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
public class ClientClass {
1010

1111
public static void main(String[] args) throws Exception {
12+
1213
Socket s = null;
1314

1415
PrintWriter pw = null;
@@ -26,23 +27,23 @@ public static void main(String[] args) throws Exception {
2627

2728
while (true) {
2829
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);
3133
pw.flush();
3234

33-
if(msg_to.equals("stop")) {
35+
if(msgTo.equals("stop")) {
3436
System.out.println(" -- success to be disconnected with server -- ");
3537
break;
38+
} else {
39+
String msgFrom = br.readLine();
40+
System.out.println("msg: " + msgFrom);
3641
}
37-
38-
String msg_from = br.readLine();
39-
System.out.println("msg: " + msg_from);
40-
4142
}
4243

43-
scan.close();
4444
s.close();
45-
45+
pw.close();
46+
br.close();
47+
scan.close();
4648
}
47-
4849
}

src/practice/network/MainClass.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
public class MainClass {
88

99
public static void main(String[] args) throws IOException {
10+
1011
/*
1112
ServerSocket ss = null;
1213
Socket s = null;
@@ -31,5 +32,4 @@ public static void main(String[] args) throws IOException {
3132
Gender gender = Gender.LESBIAN;
3233
System.out.println(gender.convertKorean());
3334
}
34-
3535
}

src/practice/network/ServerClass.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
public class ServerClass {
1010

1111
public static void main(String[] args) throws Exception{
12+
1213
ServerSocket ss = null;
1314
Socket s = null;
1415

@@ -27,19 +28,19 @@ public static void main(String[] args) throws Exception{
2728

2829
while (true) {
2930
String msg = br.readLine();
30-
System.out.println("msg: " + msg);
3131

3232
if(msg.equals("stop")) {
3333
System.out.println(" -- the client stops the dialogue -- ");
3434
break;
35+
} else {
36+
System.out.println("msg: " + msg);
37+
pw.println(" -- success to send the message to client -- ");
38+
pw.flush();
3539
}
36-
37-
pw.println(" -- success to send the message to client -- ");
38-
pw.flush();
3940
}
4041

4142
ss.close();
42-
43+
pw.close();
44+
br.close();
4345
}
44-
4546
}

0 commit comments

Comments
 (0)