Initializing the Firewall Request
So usually when we make a game we want the Windows firewall to pop up at the start, not during, simply because it would make the player have to leave the game in order to accept their firewall settings when they try to join a server.
In order to achieve this we can use the
Networking.InitializeFirewallCheck(<PORT>); method. This method can be placed anywhere at any time. It returns void and it's entire purpose is to be a quick helper on kicking off the Windows Firewall.
The way that this method works behind the scenes is that it will attempt to create a TCP connection which will trigger Windows to open up the firewall window. This connection is immediately closed once it has successfully bound so it doesn't stick around during your game.
HINT: To prevent this firewall check from happening all of the time you could use PlayerPrefs in order to save that you have already done the check. If you were to call this method every time you start the game, it will still run normally and NOT open the Firewall every time you start the game. This is due to how Windows operates, if it has already been authorized by the player, then it will not request authorization again.