Refactored c_server.c