[API]: Don't allow invalid port numbers

Change-Id: I40041f764272c7e30e92b27b75a9890212104739
Merge "[API]: Don't allow invalid port numbers"