Beej's Guide to Network Programming samples refactored to match my preferences