nix icon indicating copy to clipboard operation
nix copied to clipboard

Add `getaddrinfo` from POSIX <netdb.h>

Open Dante-Broggi opened this issue 2 years ago • 3 comments
trafficstars

I found myself implementing this and felt I should make a PR. Most of the doc comments are quotes from the posix documentation. I am uncertain how the remaining AddrInfo fields should be converted to stronger types so I just left comments. I also added the name info bit flags struct, but left it unused.

Dante-Broggi avatar Mar 15 '23 02:03 Dante-Broggi

It seems I forgot to test with the current nix MSRV, as it compiles fine with cargo 1.67.0. I'll push a fix.

Dante-Broggi avatar Mar 15 '23 02:03 Dante-Broggi

What advantages does this have over the existing DNS stuff in libstd, and in other crates?

asomers avatar Aug 07 '23 02:08 asomers

What advantages does this have over the existing DNS stuff in libstd, and in other crates?

Ability to control the DNS resolution mechanism, i.e resolve to IPv4-mapped addresses on IPv6 networks. The standard to_sock_addrs() zeroes out the hints struct:

https://github.com/rust-lang/rust/blob/9337f7afa6fda07e60d6aa5ee88e692878446782/library/std/src/sys_common/net.rs#L210

What other crates do is probably the same but nix is already a collection of safe wrappers around POSIX APIs, so it would make sense to have a safe wrapper for getaddrinfo.

pronebird avatar Aug 08 '24 12:08 pronebird