Refactoring ruby server socket demo