Utility functions for random port binding