-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConf.java
executable file
·51 lines (42 loc) · 1.21 KB
/
Conf.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
package myServer2;
/*
* AUTHOR : Min Gao
* Project1-Multi-Server Chat System
*/
import java.net.InetAddress;
import java.net.UnknownHostException;
public class Conf {
private String serverid;
// private String serverAddress;
private InetAddress serverAddress;
private int clientsPort;
private int coordinationPort;
public Conf(String serverid, String serverAddress, int clientsPort, int coordinationPort) {
super();
this.serverid = serverid;
try {
this.serverAddress = InetAddress.getByName(serverAddress);
if (this.serverAddress.getHostAddress().equals(InetAddress.getByName("localhost").getHostAddress())) {
this.serverAddress = InetAddress.getLocalHost();
}
} catch (UnknownHostException e) {
e.printStackTrace();
}
// this.serverAddress = serverAddress;
//InetAddress getHostAddress(); getlocalHost() getByName()
this.clientsPort = clientsPort;
this.coordinationPort = coordinationPort;
}
public String getServerid() {
return serverid;
}
public InetAddress getServerAddress() {
return serverAddress;
}
public int getClientsPort() {
return clientsPort;
}
public int getCoordinationPort() {
return coordinationPort;
}
}