Refactoring code to work with TCP and examples.