Does anyone know if it's possible to use getaddrinfo with unix sockets in C (AF_UNIX). I've tried a couple of things but I can't make it work. This is basically what I'm trying:
struct addrinfo hints, *res;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNIX;
hints.ai_socktype = SOCK_STREAM;
if(getaddrinfo("What should I put here?", "What should I put here?", &hints, &res) != 0){
//do sth about
}
My question is how to fill the node and service fields, in case that is possible to use it with unix sockets.
Thanks in advance.
Some implementations of getaddrinfo()
have supported AF_UNIX
socket addresses, but they no longer do so due to security concerns.
You don't really need a function to "look up" an AF_UNIX
address anyway - if you know the socket path, then you can just copy it straight into a sockaddr_un
of sufficient size. There's no resolution step for AF_UNIX
addresses - the socket name is the socket address.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With