Break out various bits of source into separate files.

This is some preparation work for code reuse - I plan on making the srv
and clt code use the same connection and thread pool code.