Check used port, fix #985.
Merge pull request #1006 from normanjaeckel/CheckPort

Check used port, fix #985.