ARES_SET_LOCAL_DEV(3)

πŸ“¦
version 1.34.9 Β· 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ ARES_SET_LOCAL_DEV ✨

okay bestie, welcome to page 3 of the Library Functions Manual β€” yes this is ARES_SET_LOCAL_DEV, and yes it's about to be your new fave πŸŽ€


πŸ’– NAME πŸ’–

ares_set_local_dev β€” bind to a specific network device when creating sockets 🫢


🌸 SYNOPSIS 🌸

#include <ares.h>

void ares_set_local_dev(ares_channel_t *channel, const char* local_dev_name)

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, the way that ares_set_local_dev works is: it makes all future sockets get bound to this device with SO_BINDTODEVICE. literally every socket from here on out, no cap πŸ’…

which means it forces your communications to go over a certain interface β€” and that's highkey useful on multi-homed machines where you've got options and you need to pick one 🧚

⚠️ okay but listen β€” this option is only supported on Linux, and there are two lil conditions: the interface must not already be bound to the socket, or the current effective user must have CAP_NET_RAW capability in the current network namespace for the option to work. both of those, real talk. πŸ‘‘

and if SO_BINDTODEVICE isn't supported at all, or the setsockopt call just... fails (probably because of permissions πŸ™ˆ), then the error is silently ignored. like, no screaming, no warning, nothing. it's giving "we don't talk about it." πŸ’€


πŸ”₯ SEE ALSO πŸ”₯


πŸ‘‘ NOTES πŸ‘‘

this function was added in c-ares 1.7.4 β€” so she's been iconic for a minute ⭐


and that's the whole page, bestie! this one's from the Library Functions Manual, dated 23 September 2024, and it's serving ARES_SET_LOCAL_DEV(3) realness. slay, go bind some sockets responsibly πŸ’–βœ¨πŸŽ€