ArgumentException: Invalid Socket

I want to know how I can handle the exceptions/errors of ArgumentException: Invalid Socket

I am using Facepunch Transport and the Netcode for game objects networking system.

Here’s my code. It’s a simple function to create a server however when creating one fails, it does not output “Failed to start host” and just breaks the game. The actual error happens rarely, but when it does it causes all sorts of issues just because it doesn’t quit the application.

private void CreateNetworkHost(SteamId targetSteamId) {
        try {
            transport.targetSteamId = targetSteamId;
            network.StartHost();
        }

        catch (Exception) {
            Debug.Log("Failed to start host");
            Application.Quit();
        }
    }
}