Core/Network: Refactored socket code, moved common operations to base Socket class