1.rewrite server.c to improve consistency;2.fix some bugs.