Moved packet sending and socket opening into functions within client.cpp