ARES_SET_S...E_CALLBACK(3)

bestie, welcome to the ARES_SET_S...E_CALLBACK(3) page from the Library Functions Manual β€” yes, the manual name is folded in right here, and we're about to make socket callbacks make sense πŸ’…βœ¨

🌸 NAME 🌸

ares_set_socket_configure_callback β€” set a socket configuration callback, periodt πŸŽ€

✨ SYNOPSIS ✨

okay so here's the exact code, no edits, no vibes-based rewrites:

#include <ares.h>

typedef int (*ares_sock_config_callback)(ares_socket_t socket_fd,
                                         int type,
                                         void *userdata)

void ares_set_socket_configure_callback(ares_channel_t *channel,
                                        ares_sock_config_callback callback,
                                        void *userdata)

πŸ’– DESCRIPTION πŸ’–

okay so ares_set_socket_configure_callback sets a callback in the given ares channel handle 🫢. Small but important caveat: it cannot be used when ARES_OPT_EVENT_THREAD is passed to ares_init_options(3) β€” like, not even a little.

Here's the moment this callback shows up: it gets invoked after the socket has been created, but before it has been connected to the remote server. That window is literally the ideal time to configure various socket options ✨.

The callback must return ARES_SUCCESS if things are fine, or return -1 to signal an error 🚨. A returned error will abort the ares operation. No cap, that's the contract.

The callback is invoked while c-ares is part-way through opening a connection. It must not call any c-ares function on the same channel; see ares_set_socket_functions(3) for that whole situation πŸ™ˆ.

πŸ”— SEE ALSO πŸ”—

πŸ¦‹ AVAILABILITY πŸ¦‹

ares_set_socket_configure_callback(3) was added in c-ares 1.11.0 ⭐.


mwah πŸ’‹ that's the whole page, bestie β€” from the Library Functions Manual, dated 6 Feb 2016, and signed with ARES_SET_S...E_CALLBACK(3) energy πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from