code refactoring and starting to add the TCP socket interface too