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