
curl_multi_info_read 함수의 두 번째 인자인 'msg'의 값이 0일 때, what 값을 0으로 받는 경우 오류를 체크하는 방법은 다음과 같습니다.
- curl_multi_info_read 함수의 세 번째 인자인 'ecode'를 확인합니다. 이 값은 오류 코드를 나타내며, 0이 아닌 경우 오류가 발생한 것입니다.
- curl_multi_info_read 함수의 네 번째 인자인 'euser'를 확인합니다. 이 값은 오류 메시지를 나타내며, 오류가 발생한 경우 이 값을 확인하여 오류를 파악할 수 있습니다.
예를 들어, 다음과 같이 curl_multi_info_read 함수를 사용하여 오류를 체크할 수 있습니다.
#hostingforum.kr
c
struct curl_msg {
CURLMcode msg;
int what;
CURLcode ecode;
void *euser;
};
struct curl_msg msg;
while ((msg.msg = curl_multi_info_read(multi_handle, &msg.what)) != CURLM_OK) {
if (msg.what == CURLMSG_DONE) {
CURL *easy = curl_easy_getinfo(multi_handle, CURLINFO_LASTEasyHandle, &easy);
CURLcode res = curl_easy_getinfo(easy, CURLINFO_LAST_LONG, &res);
if (res == CURLE_OK) {
// 오류가 발생하지 않은 경우
} else {
// 오류가 발생한 경우
printf("오류 메시지: %sn", curl_easy_strerror(res));
}
} else if (msg.what == CURLMSG_LASTMSGN) {
// 오류가 발생한 경우
printf("오류 메시지: %sn", (char *)msg.euser);
}
}
이 예제에서는 curl_multi_info_read 함수를 사용하여 오류를 체크하는 방법을 설명합니다. what 값을 0으로 받은 경우 오류 메시지를 확인하여 오류를 파악할 수 있습니다.
2025-04-25 06:05