Fix style
This commit is contained in:
parent
8d5ef8a52b
commit
e56aad5526
@ -132,8 +132,10 @@ public class ClientP2P {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverPortRange.isPortInRange(portServer)){
|
boolean serverInRange = serverPortRange.isPortInRange(portServer);
|
||||||
if(trackerPortRange.isPortInRange(portTracker)){
|
boolean trackerInRange = trackerPortRange.isPortInRange(portTracker);
|
||||||
|
|
||||||
|
if (serverInRange && trackerInRange) {
|
||||||
System.out.println("using hostname : " + hostnameServer);
|
System.out.println("using hostname : " + hostnameServer);
|
||||||
System.out.println("using port : " + portServer);
|
System.out.println("using port : " + portServer);
|
||||||
System.out.println("tracker hostname : " + hostnameTracker);
|
System.out.println("tracker hostname : " + hostnameTracker);
|
||||||
@ -182,13 +184,14 @@ public class ClientP2P {
|
|||||||
} catch (InterruptedException e) {}
|
} catch (InterruptedException e) {}
|
||||||
smudp.setStop();
|
smudp.setStop();
|
||||||
smtcp.setStop();
|
smtcp.setStop();
|
||||||
|
} else {
|
||||||
|
if (!serverInRange) {
|
||||||
|
System.err.println("SERVER: Port not in range. " + serverPortRange);
|
||||||
}
|
}
|
||||||
else{
|
if (!trackerInRange) {
|
||||||
System.out.println("\n TRACKER: Port not in range. " + trackerPortRange);
|
System.err.println("TRACKER: Port not in range. " + trackerPortRange);
|
||||||
}
|
}
|
||||||
}
|
System.exit(2);
|
||||||
else{
|
|
||||||
System.out.println("\n SERVER: Port not in range. " + serverPortRange);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,19 +66,21 @@ public class ServerP2P {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
else if (args.length == 5) {
|
else if (args.length == 5) {
|
||||||
|
isInteractive = false;
|
||||||
hostnameServer = args[1];
|
hostnameServer = args[1];
|
||||||
portServer = Integer.valueOf(Integer.parseInt(args[2]));
|
portServer = Integer.valueOf(Integer.parseInt(args[2]));
|
||||||
hostnameTracker = args[3];
|
hostnameTracker = args[3];
|
||||||
portTracker = Integer.valueOf(Integer.parseInt(args[4]));
|
portTracker = Integer.valueOf(Integer.parseInt(args[4]));
|
||||||
} else {
|
} else {
|
||||||
isInteractive = true;
|
isInteractive = true;
|
||||||
|
// configure application
|
||||||
System.out.println("Server, enter hostname to bind (default = localhost): ");
|
System.out.println("Server, enter hostname to bind (default = localhost): ");
|
||||||
hostnameServer = scanner.nextLine();
|
hostnameServer = scanner.nextLine();
|
||||||
if (hostnameServer.equals("")) {
|
if (hostnameServer.equals("")) {
|
||||||
hostnameServer = defaultHostname;
|
hostnameServer = defaultHostname;
|
||||||
System.out.println("using default hostname : " + hostnameServer);
|
System.out.println("using default hostname : " + hostnameServer);
|
||||||
}
|
}
|
||||||
System.out.println("enter port (default = " + serverPortRange.getDefaultPort() + "): ");
|
System.out.println("Enter port (default = " + serverPortRange.getDefaultPort() + "): ");
|
||||||
String portServerStr = scanner.nextLine();
|
String portServerStr = scanner.nextLine();
|
||||||
if (portServerStr.equals("")) {
|
if (portServerStr.equals("")) {
|
||||||
portServer = serverPortRange.getDefaultPort();
|
portServer = serverPortRange.getDefaultPort();
|
||||||
@ -86,13 +88,14 @@ public class ServerP2P {
|
|||||||
} else {
|
} else {
|
||||||
portServer = Integer.valueOf(Integer.parseInt(portServerStr));
|
portServer = Integer.valueOf(Integer.parseInt(portServerStr));
|
||||||
}
|
}
|
||||||
System.out.println("enter hostname of tracker (default = localhost): ");
|
// configure tracker
|
||||||
|
System.out.println("Enter hostname of tracker (default = localhost): ");
|
||||||
hostnameTracker = scanner.nextLine();
|
hostnameTracker = scanner.nextLine();
|
||||||
if (hostnameTracker.equals("")) {
|
if (hostnameTracker.equals("")) {
|
||||||
hostnameTracker = defaultHostname;
|
hostnameTracker = defaultHostname;
|
||||||
System.out.println("tracker default hostname : " + hostnameTracker);
|
System.out.println("tracker default hostname : " + hostnameTracker);
|
||||||
}
|
}
|
||||||
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 = trackerPortRange.getDefaultPort();
|
portTracker = trackerPortRange.getDefaultPort();
|
||||||
@ -102,8 +105,9 @@ public class ServerP2P {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serverPortRange.isPortInRange(portServer)){
|
boolean serverInRange = serverPortRange.isPortInRange(portServer);
|
||||||
if(trackerPortRange.isPortInRange(portTracker)){
|
boolean trackerInRange = trackerPortRange.isPortInRange(portTracker);
|
||||||
|
if (serverInRange && trackerInRange) {
|
||||||
System.out.println("using hostname : " + hostnameServer);
|
System.out.println("using hostname : " + hostnameServer);
|
||||||
System.out.println("using port : " + portServer);
|
System.out.println("using port : " + portServer);
|
||||||
System.out.println("tracker hostname : " + hostnameTracker);
|
System.out.println("tracker hostname : " + hostnameTracker);
|
||||||
@ -117,13 +121,14 @@ public class ServerP2P {
|
|||||||
Thread ttcp = new Thread(smtcp);
|
Thread ttcp = new Thread(smtcp);
|
||||||
ttcp.setName("server TCP P2P-JAVA-PROJECT");
|
ttcp.setName("server TCP P2P-JAVA-PROJECT");
|
||||||
ttcp.start();
|
ttcp.start();
|
||||||
|
} else {
|
||||||
|
if (!serverInRange) {
|
||||||
|
System.err.println("SERVER: Port not in range. " + serverPortRange);
|
||||||
}
|
}
|
||||||
else{
|
if (!trackerInRange) {
|
||||||
System.out.println("\n TRACKER: Port not in range. " + trackerPortRange);
|
System.err.println("TRACKER: Port not in range. " + trackerPortRange);
|
||||||
}
|
}
|
||||||
}
|
System.exit(2);
|
||||||
else{
|
|
||||||
System.out.println("\n SERVER: Port not in range. " + serverPortRange);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ public class Tracker {
|
|||||||
System.out.println("usage : java tracker.Tracker (interactive) or java trackerP2P.trackerP2P -- <hostname> <PORT> (" + trackerPortRange +")");
|
System.out.println("usage : java tracker.Tracker (interactive) or java trackerP2P.trackerP2P -- <hostname> <PORT> (" + trackerPortRange +")");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
} else if (args.length == 3) {
|
} else if (args.length == 3) {
|
||||||
|
isInteractive = false;
|
||||||
hostname = args[1];
|
hostname = args[1];
|
||||||
port = Integer.valueOf(Integer.parseInt(args[2]));
|
port = Integer.valueOf(Integer.parseInt(args[2]));
|
||||||
} else {
|
} else {
|
||||||
@ -88,9 +89,9 @@ public class Tracker {
|
|||||||
Thread ttcp = new Thread(tmtcp);
|
Thread ttcp = new Thread(tmtcp);
|
||||||
ttcp.setName("Tracker TCP P2P-JAVA-PROJECT");
|
ttcp.setName("Tracker TCP P2P-JAVA-PROJECT");
|
||||||
ttcp.start();
|
ttcp.start();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
System.out.println("Port not in range. " + trackerPortRange);
|
System.out.println("Port not in range. " + trackerPortRange);
|
||||||
|
System.exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user