adds socket handshake, disconnect on exit