added bounds checks for protocol, re-used udp socket