Updated socket code