fsm for connection

Signed-off-by: evanq <cppmain@gmail.com>