magic number fix

This commit is contained in:
Mei Chang van der Werff 2026-01-17 00:03:46 +01:00
commit 1da7f416d4

View file

@ -6,6 +6,8 @@ import java.util.Scanner;
public class PortChecker { public class PortChecker {
private static final int defaultPort = 8080; private static final int defaultPort = 8080;
private static final int lastValidPort = 65535;
/** /**
* Finds a free port to launch the program on. * Finds a free port to launch the program on.
@ -23,7 +25,7 @@ public class PortChecker {
while(true){ while(true){
int port = portScanner.nextInt(); int port = portScanner.nextInt();
if(port > 0 && port <=65535){ //range of valid ports if(port > 0 && port <=lastValidPort){ //range of valid ports
isPortAvailable(port); isPortAvailable(port);
return port; return port;
} }