Allow port to be specified for server
Lots more improvements and refactors after switching to /dev/tcp