ARES_SET_SOCKET_CALLBACK(3)

✨ NAME ✨

okay bestie, welcome to the ARES_SET_SOCKET_CALLBACK(3) page in the Library Functions Manual πŸ’– β€” this one is all about ares_set_socket_callback, aka Set a socket creation callback. That’s the name, that’s the vibe, periodt. πŸ‘‘


🌸 SYNOPSIS 🌸

       #include <ares.h>

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

       void ares_set_socket_callback(ares_channel_t *channel,
                                     ares_sock_create_callback callback,
                                     void *userdata)

       cc file.c -lcares

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here’s the tea β˜•: ares_set_socket_callback() sets a callback in the given ares channel handle. That callback function gets invoked after the socket has been created, and connected to the remote server. No cap. ✨

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 β€” dramatic, but that’s literally what it does. 😭

🚨 real talk: 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 the related lore. πŸ’…

🌈 SEE ALSO 🌈


πŸ‘‘ AVAILABILITY πŸ‘‘

ares_set_socket_callback(3) was added in c-ares 1.6.0. iconic behavior from way back 🫢✨


bye bestie πŸ’– β€” this page is dated 20 Nov 2009, footer-stamped ARES_SET_SOCKET_CALLBACK(3), and living in the Library Functions Manual. The c-ares 1.6.0 availability deets stay above. πŸ’…πŸŽ€

πŸ“¦ where this page comes from