Move unimplemented connection handling into function and out of main.

This centralizes everything and now it's clearer what functionality
still needs to be implemented and how it fits in along with the other
code. Also reduces fragmentation and having to jump back and forth between
the new function and the old main loop.