curl-library
How to get error connection even if timeout is disabled
Date: Mon, 15 Apr 2013 12:21:21 +0200
Hi,
I'm using curl to get a video stream. This video stream can send frame very
slowly (for example one frame every 10 minutes).
So i disabled the timeout because i don't want to receive an error if i
don't receive any frame. Nevertheless, this lead to not receive any error
is the connection is lost (for example, if the ethernet cable is
unplugged), and the curl_easy_perform function doesn't abort.
How can I use libcurl to handle that case, where timeout is disabled but
error occurs on connection error.
Here the option i use on Linux 3.2.0-4-amd64 in Mint LMDE:
// set URL to get
curl_easy_setopt(pCurlHandle, CURLOPT_URL, szMRL);
// no progress meter please
curl_easy_setopt(pCurlHandle, CURLOPT_NOPROGRESS, 0L);
// Force to don't use cached connection
curl_easy_setopt(pCurlHandle, CURLOPT_FRESH_CONNECT, 0);
curl_easy_setopt(pCurlHandle, CURLOPT_FORBID_REUSE, 0);
// disable timeout that can raise signal
curl_easy_setopt(pCurlHandle, CURLOPT_NOSIGNAL, 1L);
curl_easy_setopt(pCurlHandle, CURLOPT_TIMEOUT, 0);
curl_easy_setopt(pCurlHandle, CURLOPT_CONNECTTIMEOUT, 0);
// send all data to this function
curl_easy_setopt(pCurlHandle, CURLOPT_HEADERFUNCTION,
onWriteHeader);
curl_easy_setopt(pCurlHandle, CURLOPT_WRITEHEADER, pContext);
// send all data to this function
curl_easy_setopt(pCurlHandle, CURLOPT_WRITEFUNCTION,
onWriteData);
curl_easy_setopt(pCurlHandle, CURLOPT_WRITEDATA, pContext);
// Set progress function
curl_easy_setopt(pCurlHandle, CURLOPT_PROGRESSFUNCTION,
onProgress);
curl_easy_setopt(pCurlHandle, CURLOPT_PROGRESSDATA, pContext);
Thank you for your help.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-04-15