-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServerMain.java
61 lines (42 loc) · 1.33 KB
/
ServerMain.java
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package rmi.netflix.server;
import java.rmi.*;
//import java.lang.Thread;
import rmi.netflix.network.INetwork;
public class ServerMain {
public static void main(String[] args) {
/*if (System.getSecurityManager() == null) {
System.setSecurityManager(new SecurityManager());
}*/
int IdServer = 0;
String registry = "localhost";
try {
if (args.length >= 1) {
IdServer = Integer.parseInt(args[0]);
if (args.length == 2) {
registry = args[1];
}
} else {
System.out.println("Usage: java RunProcess <IdServer> <?confHost>");
System.exit(1);
}
}catch (NumberFormatException nfe){
System.out.println("Usage: java RunProcess <IdServer> <?confHost>\n <IdServer> is a number");
System.exit(1);
}
Server serv1;
//System.out.println("Starting process "+ IdServer);
try{
serv1 = new Server(IdServer);
//String registration = "rmi://"+ registry + "/Network";
String registration = "rmi://localhost/oNet";
INetwork iNet = (INetwork) Naming.lookup(registration);
System.out.println("registrando el server"+serv1._serverid);
iNet.registerServer(serv1);
System.out.println("I am server:"+ serv1._serverid+" and have:"+serv1._numclients+"clients");
//Thread p1Thread = new Thread(p1);
//p1Thread.start();
}catch(Exception e){
e.printStackTrace();
}
}
}