2015-01-05 2 views
1

나는 멀티 소켓을 사용하고 기능 CURLMOPT_TIMERFUNCTION에 대해, 그러나,이 APIlibcurl에서 기능 :

int timer_callback(CURLM *multi, /* multi handle */ 
       long timeout_ms, /* see above */ 
       void *userp); /* private callback pointer * 
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_TIMERFUNCTION, timer_callback); 

와 혼란, 그리고 난 시간 제한이 변경 될 때, 콜백 함수는, 그러나, 처음이라고 알고 우리는 콜백 함수를 등록합니다. 예를 들면 다음과 같습니다.

curl_multi_setopt(handle, CURLMOPT_TIMERFUNCTION, timer_cb); 
//and the callback function is 
int timer_cb(CURLM *multi, long timeout_ms,void *userp) 
{.....} 

두 번째 매개 변수 timeout_ms 값은 무엇입니까? 그리고 docs/example hiperfifo.c를 읽었습니다. 로그를 보았습니다.이 값은 1ms입니다. 어떻게이 값이 올까요?

감사

documentation에서 크 누스

답변

1

:

CURLMOPT_TIMERFUNCTION - 제한 시간이

int timer_callback(CURLM *multi, /* multi handle */<br> 
        long timeout_ms, /* see above *//<br 
        void *userp); /* private callback pointer */ 

이 콜백 F 값 수신하도록 설정 콜백 timeout 값이 변경되면 unction이 호출됩니다. timeout_ms 값은 응용 프로그램이 다중 인터페이스 (curl_multi_socket_action 및 curl_multi_perform)의 "수행 중"기능 중 하나를 호출해야하는 최신 시점입니다 - libcurl이 시간 초과 및 재시도 등의 작업을 계속할 수있게합니다. timeout_ms 값 -1은 시간 초과가 전혀 없음을 의미하고 0은 시간 초과가 이미 만료되었음을 의미합니다. libcurl에서의 고정 미래의 타임 아웃 시간이 실제로 내부 'JumpStart를'에 의해 제공되는 easy_handle가 curl_multi_add_handle() 통해 multi_handle 추가되면

-1

[이다 가능한 new_conn()는 언제든지이 경우를] 변경하는 경우에만 전화 제한하려고 타임 아웃 값으로 1ms의 타임 아웃 동작을 생성합니다. multi.c

/* Set the timeout for this multi handle to expire really soon so that it will be taken care of even when this multi handle is added in the midst of operation when only the curl_multi_socket() API is used. During that flow, only sockets that time-out or have actions will be dealt with. Since this handle has no action yet, we make sure it times out to get things to  happen. */ 
Curl_expire(data, 1); 

CURLMOPT_TIMERFUNCTION 설정 실제 타이머 콜백 의견 아래 이 도움이 Curl_expire()

희망 후에 update_timer() 내에서 호출된다.