Add a function for querying and setting the maximum incoming message size.

For TCP, unlimited message lengths are allowed.  For UDP, a maximum of
65535 is enforced.

This commit also makes the UDP receiver allocate the buffer on the
heap instead of the stack if the size is greater than 4k (arbitrarily
selected).  This buffer is freed immediately, so some bookkeeping
improvements for efficiency could be made in the future.
Fix an infinite loop in receive buffer size calculation.
Don't use LO_MAX_MSG_SIZE when validating blobs.

Simply compare with buffer size instead.
Check outgoing message size only for UDP protocol.