added function to receive handshake, and have outlined in comments the plan for the main message loop