-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWarGameServer.java
More file actions
46 lines (33 loc) · 1.28 KB
/
WarGameServer.java
File metadata and controls
46 lines (33 loc) · 1.28 KB
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
40
41
42
43
44
45
import java.net.*;
import java.nio.channels.ServerSocketChannel;
import java.util.ArrayList;
import java.io.*;
import java.rmi.Naming;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class WarGameServer extends UnicastRemoteObject {
public int clientCnt=0;
private static final int PORT = 2020;
public WarGameServer(String server,String servName) throws Exception{
super(PORT,
new RMISSLClientSocketFactory(),
new RMISSLServerSocketFactory());
}
public static void main(String[] args) throws UnknownHostException {
String mServer="127.0.0.1";
String mServName="WarGame";
System.out.println("started at"+mServer+"and use default port(1099). service name: "+mServName);
try {
//SSL-based registry 생성
Registry registry = LocateRegistry.createRegistry(PORT, new RMISSLClientSocketFactory(), new RMISSLServerSocketFactory());
//Create new impl object
WarGameImpl warGameImpl = new WarGameImpl();
registry.bind("WarGame", warGameImpl);
System.out.println("WarGame bound in registry");
} catch (Exception e) {
System.out.println("WarGame Error : " + e.getMessage());
e.printStackTrace();
}
}
}