
curl_share_close 함수를 호출한 후, 다시 curl_easy_init 함수를 호출하여 새로운 easy handle 객체를 생성한 후 curl_easy_setopt 함수를 사용하여 share 객체를 설정하였을 때, 이전에 전송한 커맨드 요청이 취소되는 이유는 share 객체가 닫히면서 이전에 전송한 커맨드 요청이 취소되는 때문입니다.
이전의 커맨드 요청을 유지하려면, curl_share_close 함수를 호출하기 전에 모든 easy handle 객체를 닫아주어야 합니다.
curl_easy_cleanup 함수를 사용하여 모든 easy handle 객체를 닫아주고, 그 후에 curl_share_close 함수를 호출하여 share 객체를 닫으세요.
예를 들어, 다음과 같이 코드를 작성할 수 있습니다.
#hostingforum.kr
c
// 다중 커맨드 요청을 처리하기 위해 share 객체를 생성합니다.
curl_share *share = curl_share_create(NULL, 0);
// 각 커맨드 요청은 easy handle 객체를 생성한 후 share 객체를 설정합니다.
curl_easy *easy1 = curl_easy_init();
curl_easy_setopt(easy1, CURLOPT_SHARE, share);
curl_easy *easy2 = curl_easy_init();
curl_easy_setopt(easy2, CURLOPT_SHARE, share);
// 다중 커맨드 요청을 전송합니다.
curl_easy_perform(easy1);
curl_easy_perform(easy2);
// 모든 easy handle 객체를 닫아줍니다.
curl_easy_cleanup(easy1);
curl_easy_cleanup(easy2);
// share 객체를 닫습니다.
curl_share_close(share);
이러한 방법으로, 이전에 전송한 커맨드 요청을 유지할 수 있습니다.
2025-08-03 18:07