Added logic for selecting TCP sockets

Also put the basic structure in place for handling connections,
disconnects, and inbound data