Not failing if  default port is in use.

Checking 10 other ports before giving up.
Refactord the server task to use the more modern block syntax.