-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerMain.java
More file actions
39 lines (28 loc) · 889 Bytes
/
ServerMain.java
File metadata and controls
39 lines (28 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.Scanner;
public class ServerMain {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Server server = new Server(8080);
while(true) {
System.out.println("1.Accept");
System.out.println("2.Send Message");
System.out.println("3.Close");
int choice = sc.nextInt();
sc.nextLine();
switch(choice) {
case 1:
server.accept();
new Thread(() -> server.receive()).start();
break;
case 2:
String msg = sc.nextLine();
server.send(msg);
break;
case 3:
server.close();
sc.close();
return;
}
}
}
}