Added ability to use UDP or TCP (default TCP)