server: cleanup socket code for future protocol implementation