Implement UDP protocol (cc#1803)

This change implements UDP support. It was written by Shixin Zeng of Atronix (original version: zsx/r3@95a057a2f03206163e6d2cf6b2a01537b4d4040b), this pull request is Shixin's code rebased onto master for easy merging.

This realises [CureCode wish #1803](http://issue.cc/r3/1803).