Refactored socket into own file