ARES_PROCESS(3)
β¨ ARES_PROCESS(3) β¨
okay bestie, so this is a page from the Library Functions Manual, all about processing events for name resolution π¦ and honestly it's giving "you're building your own event loop and you need c-ares to play nice with it."
π NAME π
ares_process_fds, ares_process_fd, ares_process β process events for name resolution π
πΈ SYNOPSIS πΈ
#include <ares.h>
/*! Events used by ares_fd_events_t */
typedef enum {
ARES_FD_EVENT_NONE = 0, /*!< No events */
ARES_FD_EVENT_READ = 1 << 0, /*!< Read event (including disconnect/error) */
ARES_FD_EVENT_WRITE = 1 << 1 /*!< Write event */
} ares_fd_eventflag_t;
/*! Type holding a file descriptor and mask of events, used by
* ares_process_fds() */
typedef struct {
ares_socket_t fd; /*!< File descriptor */
unsigned int events; /*!< Mask of ares_fd_event_t */
} ares_fd_events_t;
typedef enum {
ARES_PROCESS_FLAG_NONE = 0,
ARES_PROCESS_FLAG_SKIP_NON_FD = 1 << 0
} ares_process_flag_t;
ares_status_t ares_process_fds(ares_channel_t *channel,
const ares_fd_events_t *events,
size_t nevents,
unsigned int flags)
void ares_process_fd(ares_channel_t *channel,
ares_socket_t read_fd,
ares_socket_t write_fd)
void ares_process(ares_channel_t *channel,
fd_set *read_fds,
fd_set *write_fds)
π DESCRIPTION π
so here's the tea β these functions are for you if you are an integrator who has chosen not to use the EventThread that you'd normally get by passing ARES_OPT_EVENT_THREAD to ares_init_options. Basically the vibe is: you already have your own event loop doing event notifications for a whole bunch of file descriptors, and you wanna do the exact same thing when you hook up with c-ares. iconic, honestly π«Ά
π
ares_process_fds β the main character
The ares_process_fds(3) function handles input/output events on file descriptors and the timeouts associated with queries that are pending on the channel identified by channel. The file descriptors you want processed get passed in as an array of ares_fd_events_t data structures in the fd member, and the events are a bitwise mask of ares_fd_eventflag_t in the event member. β¨
You can also use this function to process timeouts β just pass NULL to the events member with an nevents value of 0. π Flags can be specified in the flags field too, and those are defined in ares_process_flag_t.
ARES_PROCESS_FLAG_SKIP_NON_FDβ specify this and you specifically skip any processing that isn't related to the file descriptor events you passed in. Examples of what gets skipped include timeout processing and cleanup handling. This is lowkey perfect if you know you're gonna be sending multipleares_process_fds(3)requests and you wanna skip all that extra processing. BUT β οΈ β the integrator must send the final request with the flag so that timeout and other processing gets performed before their event loop waits on additional events. do not skip this step bestie.
It is allowable to use an ares_fd_events_t with an events member of value ARES_FD_EVENT_NONE (0) when there are no events for a given file descriptor β for instance if an integrator just wants to maintain one big array with all possible file descriptors and update readiness via the event member. ποΈ
This function will return ARES_ENOMEM in out of memory conditions, otherwise it will return ARES_SUCCESS. π«‘
This function is recommended overares_process_fd(3)because it can handle processing of multiple file descriptors at once β which means you skip repeating additional logic like timeout processing, which you'd have to do if you calledares_process_fd(3)for multiple file descriptors that got notified at the same time. efficiency slay π
This function is typically used with the ARES_OPT_SOCK_STATE_CB option.
ares_timeout(3) should be used to retrieve the desired timeout, and when the timeout expires, the integrator must call ares_process_fds(3) with a NULL events array (or ares_process_fd(3) with both sockets set to ARES_SOCKET_BAD). There is no need to do this if events are also delivered for any file descriptors, because timeout processing will automatically be handled by any call to ares_process_fds(3) or ares_process_fd(3). π§
π ares_process_fd β the smaller one
The ares_process_fd(3) function is the same as ares_process_fds(3) except it can only process a single read and write file descriptor at a time. New integrators should use ares_process_fds(3) if possible. π
π ares_process β the deprecated one, tread carefully
The ares_process(3) function works in the same manner, except it works on fd_sets as is used by select(3) and retrieved by ares_fds(3).
This method is deprecated and should not be used in modern applications due to known limitations in the select(3) implementation. like, fr fr, leave it in the past bestie π
β AVAILABILITY β
ares_process_fds(3) was introduced in c-ares 1.34.0. π
π¦ SEE ALSO π¦
ares_fds(3)ares_timeout(3)ares_init_options(3)withARES_OPT_EVENT_THREADorARES_OPT_SOCK_STATE_CB
and that's the whole page bestie, no cap π this one's dated 25 July 1998 and it comes to you from the c-ares crew β go forth and process those events, you absolute legend πβ¨
π¦ where this page comes from
- alpine 3.22: c-ares-doc 1.34.9-r0 Β· MIT
- alpine 3.23: c-ares-doc 1.34.9-r0 Β· MIT
- alpine 3.24: c-ares-doc 1.34.9-r0 Β· MIT
- arch rolling: c-ares 1.34.9-1 Β· MIT
- centos-stream 10: c-ares-devel 1.34.9-1.el10 Β· MIT
- debian trixie: libc-ares-dev 1.34.5-1+deb13u1 Β· MIT
- fedora 43: c-ares-devel 1.34.5-2.fc43 Β· MIT
- fedora 43: c-ares-devel 1.34.5-2.fc43 Β· MIT
- fedora 43: c-ares-devel 1.34.8-1.fc43 Β· MIT
- fedora 43: c-ares-devel 1.34.8-1.fc43 Β· MIT
- fedora 44: c-ares-devel 1.34.6-3.fc44 Β· MIT
- fedora 44: c-ares-devel 1.34.6-3.fc44 Β· MIT
- fedora 44: c-ares-devel 1.34.8-1.fc44 Β· MIT
- fedora 44: c-ares-devel 1.34.8-1.fc44 Β· MIT
- nixos 26.05: c-ares 1.34.9
- nixpkgs unstable: c-ares 1.34.8
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- opensuse-leap 16.0: c-ares-devel 1.34.8-160000.1.1 Β· MIT
- ubuntu questing: libc-ares-dev 1.34.5-1
- ubuntu questing: libc-ares-dev 1.34.5-1ubuntu0.1
- ubuntu resolute: libc-ares-dev 1.34.6-1 Β· MIT
- ubuntu resolute: libc-ares-dev 1.34.6-1ubuntu0.1
- ubuntu resolute: libc-ares-dev 1.34.6-1ubuntu0.2 Β· MIT
- ubuntu stonking: libc-ares-dev 1.34.8-1 Β· MIT
- π the page's license: MIT
- Copyright 1998 by the Massachusetts Institute of Technology
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms