ARES_GETSOCK(3)
π ARES_GETSOCK(3) β Library Functions Manual π
okay bestie, gather round, because we're talking about ares_getsock β and the tea is that she's deprecated, so this is giving "beloved but retired icon" energy π
β¨ NAME β¨
ares_getsock β get socket descriptors to wait on (deprecated) π«Ά
πΈ SYNOPSIS πΈ
#include <ares.h>
int ares_getsock(const ares_channel_t *channel, ares_socket_t *socks,
int numsocks);
π¦ DESCRIPTION π¦
so like. ares_getsock hands you the whole set of socket descriptors that your app should be waiting on β for reading and/or writing β so that the name service queries pending on the channel identified by channel can actually get processed. π
The socket descriptors get dropped into the socket descriptor array that socks points at. And numsocks? That's the size of the array you passed in, measured in number of ints. no cap.
β οΈ heads up bestie: this function can only ever report up to 16 sockets. if more than 16 are in use, they're justβ¦ not reported back. literally ghosted. π
π RETURN VALUES π
ares_getsock returns a bitmask telling you what actions to wait for on each of the different sockets. and the ares.h header file is your bestie here, because it ships these convenience macros so you can pull the info out properly:
#define ARES_GETSOCK_MAXNUM 16 /* ares_getsock() can return info about
this many sockets */
#define ARES_GETSOCK_READABLE(bits,num) (bits & (1<< (num)))
#define ARES_GETSOCK_WRITABLE(bits,num) (bits & (1 << ((num) + ARES_GETSOCK_MAXNUM)))
π NOTES π
okay so the lore: this function was added in c-ares 1.3.1 and then deprecated in c-ares 1.20.0 β because of the implementation of ARES_OPT_MAX_UDP_QUERIES, which makes it likely to exceed 16 open file descriptors. the limit said "not today" and honestly? she's right. π
so the recommendation is: use ARES_OPT_EVENT_THREAD passed to ares_init_options(3), or use socket state callbacks (ARES_OPT_SOCK_STATE_CB) registered via ares_init_options(3). that's the move, periodt. β¨
π SEE ALSO π
and that's the whole page, bestie! this little relic was dated 11 March 2010, and it lives in the Library Functions Manual β so if you're out here reading it in the present day, know that you're reading a certified classic. stay hydrated, go use ARES_OPT_EVENT_THREAD, mwah ππ§πΈ
π¦ 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 Daniel Stenberg
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms