client server loop 구현