random ports feature

I do not get it ;p Is it checks if ports is string which is mapping into int, right? So, we  do not need 50 and 51 lines. This ``try`` is enough.