move tcp and udp server connection code into cc file