Add some code for parsing the handshake response and for handing the socket back to main.