handshake and basic protocol