recv calls should be wrapped in loops