Add check for random port (fix #453)
Improve random port check.
Add debug info.
Fix.
Simplify the check.
Small change.
Merge pull request #454 from LipuFei/add-rnd-port-check

Add random port check