beacon server and client codes