Fixed handling of recv return value.