|
|
|
@ -90,31 +90,19 @@ public class ServerP2P {
|
|
|
|
|
System.out.println("enter tracker's port (default = " + trackerPortRange.getDefaultPort() + "): ");
|
|
|
|
|
String portTrackerStr = scanner.nextLine();
|
|
|
|
|
if(portTrackerStr.equals("")){
|
|
|
|
|
portTracker = serverPortRange.getDefaultPort();
|
|
|
|
|
portTracker = trackerPortRange.getDefaultPort();
|
|
|
|
|
System.out.println("using default port : " + portTracker);
|
|
|
|
|
} else {
|
|
|
|
|
portTracker = Integer.valueOf(Integer.parseInt(portTrackerStr));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (serverPortRange.isPortInRange(portServer)){
|
|
|
|
|
if(trackerPortRange.isPortInRange(portTracker)){
|
|
|
|
|
System.out.println("using hostname : " + hostnameServer);
|
|
|
|
|
if(serverPortRange.isPortInRange(portServer)) {
|
|
|
|
|
System.out.println("using port : " + portServer);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
System.out.println("Port not in range. " + serverPortRange);
|
|
|
|
|
portServer = serverPortRange.getDefaultPort();
|
|
|
|
|
}
|
|
|
|
|
System.out.println("tracker hostname : " + hostnameTracker);
|
|
|
|
|
|
|
|
|
|
if(trackerPortRange.isPortInRange(portTracker)) {
|
|
|
|
|
System.out.println("using port : " + portTracker);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
System.out.println("Port not in range. " + trackerPortRange);
|
|
|
|
|
portTracker = trackerPortRange.getDefaultPort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println("tracker port : " + portTracker);
|
|
|
|
|
ServerP2P s = new ServerP2P(hostnameServer, portServer, hostnameTracker, portTracker);
|
|
|
|
|
ServerManagementUDP smudp = new ServerManagementUDP(s.directories.getDataHomeDirectory() + subdir, s.server, s.tracker, s.logger);
|
|
|
|
|
ServerManagementTCP smtcp = new ServerManagementTCP(s.directories.getDataHomeDirectory() + subdir, s.server, s.tracker, s.logger);
|
|
|
|
@ -125,4 +113,12 @@ public class ServerP2P {
|
|
|
|
|
ttcp.setName("server TCP P2P-JAVA-PROJECT");
|
|
|
|
|
ttcp.start();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
System.out.println("\n TRACKER: Port not in range. " + trackerPortRange);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
System.out.println("\n SERVER: Port not in range. " + serverPortRange);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|