Fixes issue 1017

Attempts to convert port to integer and raises an error if it couldn't.

https://github.com/rethinkdb/rethinkdb/issues/1017