Create common.cpp

Common functions for client.cpp and server.cpp