switch to network byte order, add error checking
fix printing of port number