receive with timeout function