refactor things to use const args and static functions

This does a bunch of things:
 * define most variables in main to have static linkage
 * define default settings more cleanly in main
 * use static functions wherever possible in tcpserver
 * use static functions wherever possible in udpserver
 * make more functions const-correct (also makes them thread-safe)

Besides cleaning up the interfaces and defaults, this should have some small
performance improvements since the compiler can optimize static functions more
aggressively.

There's still further work to improve static correctness in the other header
files.