separate socket code