extract simple handshake, add todo to use block mode