Add support for custom port

Hello @nicks, 

Please review the following commits I made in branch 'xiao-custom-port'.

6d4dfdb525af023be7cec78b46c4e0c84dce256d (2013-06-28 11:43:21 -0700)
Add support for custom port


R=@nicks