implement of server.cpp