implements simple handshake.