Buy commercial curl support. We
help you work out your issues, debug your libcurl applications, use the API,
port to new platforms, add new features and more. With a team lead by the
curl founder Daniel himself.
Re: libcurl socket interface and timeout (ephiperfifo example)
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Daniel Stenberg via curl-library <curl-library_at_lists.haxx.se>
Date: Thu, 26 Jun 2025 08:42:20 +0200 (CEST)
On Mon, 23 Jun 2025, Nicolas Martin via curl-library wrote:
> 1- multi_timer_cb
> It's an optimization so libcurl will ask to timeout sooner and data will be
> read/written without waiting for a full timeout.
It's more than "an optimization". In order to function properly, to do
timeouts and things correctly libcurl sometimes need to be invoked again
without any new socket activity.
This callback tells the application to set the timer for when libcurl wants to
be told the next time.
> So in my application, it's OK not to use this timer.
No. Don't do that. Failing to use the timer properly will probably make
libcurl behave unreliably. Managing the timer should not be complicated nor a
lot of work for an application.
> 2- timer_cb
> I don't understand the need to set this timer. If epoll exits with code 0,
> that means a timeout has passed and we can call
> curl_multi_socket_action(CURL_SOCKET_TIMEOUT). Why use a timerfd for this ?
This is the callback called by the event library when the timer expires. The
timer set to the time libcurl told the application about in the
CURLMOPT_SOCKETFUNCTION callback invoke.
> I'm wondering if there is an existing function in libcurl that is able to
> say if a file descriptor belongs to libcurl or not ?
No, there isn't.
Date: Thu, 26 Jun 2025 08:42:20 +0200 (CEST)
On Mon, 23 Jun 2025, Nicolas Martin via curl-library wrote:
> 1- multi_timer_cb
> It's an optimization so libcurl will ask to timeout sooner and data will be
> read/written without waiting for a full timeout.
It's more than "an optimization". In order to function properly, to do
timeouts and things correctly libcurl sometimes need to be invoked again
without any new socket activity.
This callback tells the application to set the timer for when libcurl wants to
be told the next time.
> So in my application, it's OK not to use this timer.
No. Don't do that. Failing to use the timer properly will probably make
libcurl behave unreliably. Managing the timer should not be complicated nor a
lot of work for an application.
> 2- timer_cb
> I don't understand the need to set this timer. If epoll exits with code 0,
> that means a timeout has passed and we can call
> curl_multi_socket_action(CURL_SOCKET_TIMEOUT). Why use a timerfd for this ?
This is the callback called by the event library when the timer expires. The
timer set to the time libcurl told the application about in the
CURLMOPT_SOCKETFUNCTION callback invoke.
> I'm wondering if there is an existing function in libcurl that is able to
> say if a file descriptor belongs to libcurl or not ?
No, there isn't.
-- / daniel.haxx.se || https://rock-solid.curl.dev -- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2025-06-26