There is a program called PC^2 (a programming contest judging system). You can submit java files to it, and it will compile/run it.
I have a program that creates a socket, when I submit this to PC^2 it runs it fine, but I can’t access the url (http://ip:port/) on my web browser. But when I quit PC^2 (my program is still running) it works when I hit refresh on my web browser. This means that PC^2 is somehow blocking the port, but not occupying it (i.e. making it’s own ServerSocket that occupies the port) because if it was occupying it, then my program would have thrown an exception and quit.
What are possible ways that a Java program can do this? And since PC^2 is closed source, I can’t look there.
Only one program at a time could listen to a certain port.
Same happens if you start tomcat twice using the some port
This has nothing to do with java. That is how sockets work