More robust setup of TCP/UDP listeners