C++ class for tcp/udp communication