Fix the port for the protocols, and handle the case where the listener
crashes because the port is already used.
Refactor the listeners, reduce the code